Porting solution with multiple startup projects from .NET Framework 4.7.1 to .NET Core 2.1











up vote
4
down vote

favorite












I'm in the process of migrating my solution from .NET Standard (targeting .NET Framework 4.7.1) to .NET Core (targeting netcoreapp2.1). My solution consists of 12 projects, two of which are web API projects that both need to run simultaneously.



I changed the targets in all my solution's .csproj from "net471" to "netcoreapp2.1". In a few cases I also had to update the APIs in code. There are still several warnings I'm dealing with regarding potential package incompatibility.



However my main problem is the following error:




Error CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. Foo.Api D:CodeProductFoosrcFoo.ApiProgram.cs 9 Active




My solution has two startup projects, as it consists of two APIs that are related but separate. I don't want to specify one as the main as I need them both to start up when starting my solution, and under .NET Framework this was no problem.



Is it possible to have these projects start up together?



EDIT



Note that if I add <StartupObject>Foo.Api.Program</StartupObject> to one of my API projects as described here, I can successfully get that project to start. I think this is equivalent to compling with /main. I cannot, however, get the other API project to start the same way.



There are definitely only these two Main methods in my solution, here is the results of a find on void Main:



enter image description here










share|improve this question
























  • this may help: andrewlock.net/…
    – JohnB
    8 hours ago










  • Thanks @JohnB but I believe that link deals with this error being generated unit test project main method conflicting with the production project main method. In this case, you can suppress the generation of the test project main method. In my case I want and need both projects to have a main method that starts up. My solution cannot involve suppressing one of my projects.
    – Ivan
    7 hours ago










  • A C# program (not solution) can only have one Program.Main(). Main is the first method run when the program starts, so the compiler needs to know which one is the real one, and it can't if you have two.
    – DaImTo
    7 hours ago












  • Thanks for the comment @DalmTo, but both my startup projects (not solution) have exactly one Program.Main() so they should both be able to run.
    – Ivan
    6 hours ago










  • @Ivan the error message you are getting contradicts that. I suggest that you check again.
    – DaImTo
    6 hours ago















up vote
4
down vote

favorite












I'm in the process of migrating my solution from .NET Standard (targeting .NET Framework 4.7.1) to .NET Core (targeting netcoreapp2.1). My solution consists of 12 projects, two of which are web API projects that both need to run simultaneously.



I changed the targets in all my solution's .csproj from "net471" to "netcoreapp2.1". In a few cases I also had to update the APIs in code. There are still several warnings I'm dealing with regarding potential package incompatibility.



However my main problem is the following error:




Error CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. Foo.Api D:CodeProductFoosrcFoo.ApiProgram.cs 9 Active




My solution has two startup projects, as it consists of two APIs that are related but separate. I don't want to specify one as the main as I need them both to start up when starting my solution, and under .NET Framework this was no problem.



Is it possible to have these projects start up together?



EDIT



Note that if I add <StartupObject>Foo.Api.Program</StartupObject> to one of my API projects as described here, I can successfully get that project to start. I think this is equivalent to compling with /main. I cannot, however, get the other API project to start the same way.



There are definitely only these two Main methods in my solution, here is the results of a find on void Main:



enter image description here










share|improve this question
























  • this may help: andrewlock.net/…
    – JohnB
    8 hours ago










  • Thanks @JohnB but I believe that link deals with this error being generated unit test project main method conflicting with the production project main method. In this case, you can suppress the generation of the test project main method. In my case I want and need both projects to have a main method that starts up. My solution cannot involve suppressing one of my projects.
    – Ivan
    7 hours ago










  • A C# program (not solution) can only have one Program.Main(). Main is the first method run when the program starts, so the compiler needs to know which one is the real one, and it can't if you have two.
    – DaImTo
    7 hours ago












  • Thanks for the comment @DalmTo, but both my startup projects (not solution) have exactly one Program.Main() so they should both be able to run.
    – Ivan
    6 hours ago










  • @Ivan the error message you are getting contradicts that. I suggest that you check again.
    – DaImTo
    6 hours ago













up vote
4
down vote

favorite









up vote
4
down vote

favorite











I'm in the process of migrating my solution from .NET Standard (targeting .NET Framework 4.7.1) to .NET Core (targeting netcoreapp2.1). My solution consists of 12 projects, two of which are web API projects that both need to run simultaneously.



I changed the targets in all my solution's .csproj from "net471" to "netcoreapp2.1". In a few cases I also had to update the APIs in code. There are still several warnings I'm dealing with regarding potential package incompatibility.



However my main problem is the following error:




Error CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. Foo.Api D:CodeProductFoosrcFoo.ApiProgram.cs 9 Active




My solution has two startup projects, as it consists of two APIs that are related but separate. I don't want to specify one as the main as I need them both to start up when starting my solution, and under .NET Framework this was no problem.



Is it possible to have these projects start up together?



EDIT



Note that if I add <StartupObject>Foo.Api.Program</StartupObject> to one of my API projects as described here, I can successfully get that project to start. I think this is equivalent to compling with /main. I cannot, however, get the other API project to start the same way.



There are definitely only these two Main methods in my solution, here is the results of a find on void Main:



enter image description here










share|improve this question















I'm in the process of migrating my solution from .NET Standard (targeting .NET Framework 4.7.1) to .NET Core (targeting netcoreapp2.1). My solution consists of 12 projects, two of which are web API projects that both need to run simultaneously.



I changed the targets in all my solution's .csproj from "net471" to "netcoreapp2.1". In a few cases I also had to update the APIs in code. There are still several warnings I'm dealing with regarding potential package incompatibility.



However my main problem is the following error:




Error CS0017 Program has more than one entry point defined. Compile with /main to specify the type that contains the entry point. Foo.Api D:CodeProductFoosrcFoo.ApiProgram.cs 9 Active




My solution has two startup projects, as it consists of two APIs that are related but separate. I don't want to specify one as the main as I need them both to start up when starting my solution, and under .NET Framework this was no problem.



Is it possible to have these projects start up together?



EDIT



Note that if I add <StartupObject>Foo.Api.Program</StartupObject> to one of my API projects as described here, I can successfully get that project to start. I think this is equivalent to compling with /main. I cannot, however, get the other API project to start the same way.



There are definitely only these two Main methods in my solution, here is the results of a find on void Main:



enter image description here







c# .net-core visual-studio-2017 asp.net-core-webapi porting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 hours ago

























asked 8 hours ago









Ivan

2,48151847




2,48151847












  • this may help: andrewlock.net/…
    – JohnB
    8 hours ago










  • Thanks @JohnB but I believe that link deals with this error being generated unit test project main method conflicting with the production project main method. In this case, you can suppress the generation of the test project main method. In my case I want and need both projects to have a main method that starts up. My solution cannot involve suppressing one of my projects.
    – Ivan
    7 hours ago










  • A C# program (not solution) can only have one Program.Main(). Main is the first method run when the program starts, so the compiler needs to know which one is the real one, and it can't if you have two.
    – DaImTo
    7 hours ago












  • Thanks for the comment @DalmTo, but both my startup projects (not solution) have exactly one Program.Main() so they should both be able to run.
    – Ivan
    6 hours ago










  • @Ivan the error message you are getting contradicts that. I suggest that you check again.
    – DaImTo
    6 hours ago


















  • this may help: andrewlock.net/…
    – JohnB
    8 hours ago










  • Thanks @JohnB but I believe that link deals with this error being generated unit test project main method conflicting with the production project main method. In this case, you can suppress the generation of the test project main method. In my case I want and need both projects to have a main method that starts up. My solution cannot involve suppressing one of my projects.
    – Ivan
    7 hours ago










  • A C# program (not solution) can only have one Program.Main(). Main is the first method run when the program starts, so the compiler needs to know which one is the real one, and it can't if you have two.
    – DaImTo
    7 hours ago












  • Thanks for the comment @DalmTo, but both my startup projects (not solution) have exactly one Program.Main() so they should both be able to run.
    – Ivan
    6 hours ago










  • @Ivan the error message you are getting contradicts that. I suggest that you check again.
    – DaImTo
    6 hours ago
















this may help: andrewlock.net/…
– JohnB
8 hours ago




this may help: andrewlock.net/…
– JohnB
8 hours ago












Thanks @JohnB but I believe that link deals with this error being generated unit test project main method conflicting with the production project main method. In this case, you can suppress the generation of the test project main method. In my case I want and need both projects to have a main method that starts up. My solution cannot involve suppressing one of my projects.
– Ivan
7 hours ago




Thanks @JohnB but I believe that link deals with this error being generated unit test project main method conflicting with the production project main method. In this case, you can suppress the generation of the test project main method. In my case I want and need both projects to have a main method that starts up. My solution cannot involve suppressing one of my projects.
– Ivan
7 hours ago












A C# program (not solution) can only have one Program.Main(). Main is the first method run when the program starts, so the compiler needs to know which one is the real one, and it can't if you have two.
– DaImTo
7 hours ago






A C# program (not solution) can only have one Program.Main(). Main is the first method run when the program starts, so the compiler needs to know which one is the real one, and it can't if you have two.
– DaImTo
7 hours ago














Thanks for the comment @DalmTo, but both my startup projects (not solution) have exactly one Program.Main() so they should both be able to run.
– Ivan
6 hours ago




Thanks for the comment @DalmTo, but both my startup projects (not solution) have exactly one Program.Main() so they should both be able to run.
– Ivan
6 hours ago












@Ivan the error message you are getting contradicts that. I suggest that you check again.
– DaImTo
6 hours ago




@Ivan the error message you are getting contradicts that. I suggest that you check again.
– DaImTo
6 hours ago

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53370743%2fporting-solution-with-multiple-startup-projects-from-net-framework-4-7-1-to-ne%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53370743%2fporting-solution-with-multiple-startup-projects-from-net-framework-4-7-1-to-ne%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules