有人能解释这两个中的csproj文件的目的(VS2017):.NET核心RuntimeIdentifier VS TargetFramework
<TargetFramework>netstandard1.6</TargetFramework>
<RuntimeIdentifier>win7</RuntimeIdentifier>
我刚刚从VS2015迁移,现在因为它看起来我应该不能发布我的网络API只使用一个目标框架。另外我不能指定多个RID。 所有这些改变的事情让我感到沮丧。没有什么是从头开始的,应该一遍又一遍地克服某些事
我只想在Windows上开发我的web-api,在这里运行xUnit测试,然后部署web-api以在Linux(ubuntu)服务器上运行。 我应该把两个参数放在csproj中? 高度赞赏链接与良好的解释。
UPDATE1
我有引用.NET核心库的Web API。从VS2015迁移的所有东西。现在在根项目中我有 <TargetFrameworks>netcoreapp1.1;net461</TargetFrameworks>
。当我通过VS2017发布我的错误:
C:\Program Files\dotnet\sdk\1.0.3\Sdks\Microsoft.NET.Sdk\buildCrossTargeting\Microsoft.NET.Sdk.targets(31,5): error : The 'Publish' target is not supported without specifying a target framework. The current project targets multiple frameworks, please specify the framework for the published application.
但我指定的目标框架,发布为netcoreapp1.1
。好的。然后我按照以下建议更新我的csproj <PropertyGroup Condition="$(TargetFramework)'=='netcoreapp1.1'"> <RuntimeIdentifier>ubuntu.16.10-x64</RuntimeIdentifier> </PropertyGroup>
。 但现在我甚至不能建立应用程序,得到错误:
5>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(92,5): error : Assets file '\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v1.1/ubuntu.16.10-x64'. Ensure you have restored this project for TargetFramework='netcoreapp1.1' and RuntimeIdentifier='ubuntu.16.10-x64'.
我只是想在窗口8.1/windows7的VS2017开发和部署到Ubuntu 16.10。 我做错了什么?
UPDATE2
我在溶液中具有8个项目。其中3个是xUnit测试。因此我们有5个项目。其中4个是类库,1个是我的网络应用程序。 所有4类库有这样的:
<TargetFrameworks>netstandard1.6;net461</TargetFrameworks>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
我的web应用程序:
<TargetFrameworks>netcoreapp1.1;net461</TargetFrameworks>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
如何发布我的web应用程序?
' netstandard1.0; net451 TargetFrameworks>时使用的.Net标准他'是不必要的。你正在使用许多过时的做法 –
我试过了,它不适合我。查看我在这个问题上的更新。 – Alezis
@Alezis:阅读邮件;)当你有超过1个目标时,你必须告诉'dotnet publish'发布哪个版本。 https://docs.microsoft.com/en-us/dotnet/articles/core/tools/dotnet-publish,即'dotnet publish --runtime ubuntu.16.10-x64'。在'netstandard1.0; net451'中''net451'已经过时了(因为'netstandard1.0'在.NET 4.5及更高版本上运行,但是如果你只使用1.3(.NET 4.6)中的特性,那么'netstandard1.3 ; net451'可以用于创建两个版本,请参阅https://docs.microsoft.com/en-us/dotnet/articles/standard/library – Tseng