将具有多个启动项目的解决方案从 .NET Framework 4.7.1 移植到 .NET Core 2.1 [英] Porting a solution with multiple startup projects from .NET Framework 4.7.1 to .NET Core 2.1

查看:23
本文介绍了将具有多个启动项目的解决方案从 .NET Framework 4.7.1 移植到 .NET Core 2.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将我的解决方案从 .NET Standard(面向 .NET Framework 4.7.1)迁移到 .NET Core(面向 netcoreapp2.1).我的解决方案由 12 个项目组成,其中两个是需要同时运行的 Web API 项目.

我将所有解决方案的 .csproj 中的目标从net471"更改为netcoreapp2.1".在少数情况下,我还必须更新代码中的 API.关于潜在的包不兼容问题,我仍然在处理几个警告.

但是我的主要问题是以下错误:

<块引用>

错误 CS0017 程序定义了多个入口点.使用/main 编译以指定包含入口点的类型.Foo.Api D:CodeProductFoosrcFoo.ApiProgram.cs 9 活动

我的解决方案有两个启动项目,因为它由两个相关但独立的 API 组成.我不想指定一个作为主要的,因为在启动我的解决方案时我需要它们都启动,而在 .NET Framework 下这没问题.

是否可以让这些项目一起启动?

请注意,如果我将 Foo.Api.Program 添加到我的 API 项目之一

解决方案

我的问题已经解决,但我仍然不确定是什么原因造成的.

我引用了几个给出以下警告的包:

<块引用>

警告 NU1701 包CacheManager.SystemRuntimeCaching 1.1.2"是使用.NETFramework,Version=v4.6.1"而不是项目目标框架.NETCoreApp,Version=v2.1"恢复的.此软件包可能与您的项目不完全兼容.

我升级了其中的大部分,除了上面的例外,我能够同时运行和调试两个启动项目而不会出错.我的猜测是与这些软件包之一存在某种冲突.

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?

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 compiling with /main. I cannot, however, get the other API project to start the same way. Instead, I can dotnet run that project and have them both running. However, the compile time error needs to be resolved for it to get through our release pipeline.

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

解决方案

My problem is resolved, but I am still not sure what caused it.

I was referencing a few packages that gave the following warning:

Warning NU1701 Package 'CacheManager.SystemRuntimeCaching 1.1.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.1'. This package may not be fully compatible with your project.

I upgraded most of them, with the exception above, and I was able to run and debug both startup projects simultaneously without error. My guess is there was some kind of conflict with one of these packages.

这篇关于将具有多个启动项目的解决方案从 .NET Framework 4.7.1 移植到 .NET Core 2.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆