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
:
c# .net-core visual-studio-2017 asp.net-core-webapi porting
|
show 3 more comments
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
:
c# .net-core visual-studio-2017 asp.net-core-webapi porting
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 oneProgram.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
|
show 3 more comments
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
:
c# .net-core visual-studio-2017 asp.net-core-webapi porting
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
:
c# .net-core visual-studio-2017 asp.net-core-webapi porting
c# .net-core visual-studio-2017 asp.net-core-webapi porting
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 oneProgram.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
|
show 3 more comments
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 oneProgram.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
|
show 3 more comments
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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