有人可以解释一下 csproj 文件中这两个的目的吗?(VS2017)
<TargetFramework>netstandard1.6</TargetFramework>
<RuntimeIdentifier>win7</RuntimeIdentifier>
我刚从VS2015迁移,现在无法发布我的Web API,因为看起来我应该只使用一个目标框架。此外,我无法指定多个RID。 所有这些变化让我感到沮丧。什么都无法从头开始运行,我必须一次又一次地克服问题。
我只想在Windows上开发我的Web API,在此处运行xUnit测试,然后将Web API部署到Linux(Ubuntu)服务器上运行。 我应该在csproj文件的这两个参数中放入什么? 非常感谢提供解释的链接。
更新1
我有一个带有引用的.NET Core库的Web API。所有东西都从VS2015迁移过来。现在在根项目中,我有 netcoreapp1.1;net461。当我通过VS2017进行发布时,我收到错误消息:
C:\Program Files\dotnet\sdk\1.0.3\Sdks\Microsoft.NET.Sdk\buildCrossTargeting\Microsoft.NET.Sdk.targets(31,5): error : 未指定目标框架不支持“Publish”目标。当前项目针对多个框架,请为发布的应用程序指定框架。
但是我在发布中指定了目标框架为
netcoreapp1.1
。
好的。然后我根据下面的建议更新了我的csproj文件,添加了<PropertyGroup Condition="$(TargetFramework)'=='netcoreapp1.1'"> <RuntimeIdentifier>ubuntu.16.10-x64</RuntimeIdentifier> </PropertyGroup>
。
但是现在我甚至无法构建应用程序,出现错误:
我只想使用VS2017在Windows 8.1/Windows 7上进行开发,并部署到Ubuntu 16.10上。 我做错了什么?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个解决方案中的项目。其中3个是xUnit测试。因此我们有5个项目。这5个项目中有4个是类库,1个是我的Web应用程序。 所有这4个类库都具有以下内容:
<TargetFrameworks>netstandard1.6;net461</TargetFrameworks>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
我的网络应用程序:
<TargetFrameworks>netcoreapp1.1;net461</TargetFrameworks>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
如何发布我的网页应用?
dotnet publish --runtime ubuntu.16.10-x64
并得到相同的错误。正如我所说,我的根应用程序(web-app)针对netcoreapp1.1;net461
。我没有使用net451
,只在我的5个项目中使用了3个项netcoreapp1.1
net461
netstandard1.6
。 - Alezisnetstandard1.6
,然后执行dotnet publish -c release -r ubuntu.16.10-x64
? - J. Doe