- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有人可以解释一下csproj文件(VS2017)中这两个的用途吗:
<TargetFramework>netstandard1.6</TargetFramework>
<RuntimeIdentifier>win7</RuntimeIdentifier>
我刚刚从 VS2015 迁移,现在无法发布我的 Web api,因为看起来我应该只使用一个目标框架。此外,我无法指定多个 RID。所有这些变化让我感到沮丧。没有什么是从头开始的,应该一遍又一遍地克服一些事情。
我只想在 Windows 上开发我的 web-api,在此处运行 xUnit 测试,然后部署 web-api 以在 Linux (ubuntu) 服务器上运行。我应该在 csproj 的两个参数中放入什么?高度赞赏具有良好解释的链接。
更新1
我有带有引用的 .net 核心库的 Web API。一切都是从 VS2015 迁移的。现在在根项目中我有 <TargetFrameworks>netcoreapp1.1;net461</TargetFrameworks>
。当我通过 VS2017 发布时出现错误:
C:\ProgramFiles\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 atarget framework. The current project targets multiple frameworks,please specify the framework for the published application.
但我已在发布中指定目标框架为 netcoreapp1.1
。好的。然后我用 <PropertyGroup Condition="$(TargetFramework)'=='netcoreapp1.1'"> <RuntimeIdentifier>ubuntu.16.10-x64</RuntimeIdentifier> </PropertyGroup>
更新了我的 csproj如下所示。但现在我什至无法构建应用程序,出现错误:
5>C:\Program Files (x86)\Microsoft VisualStudio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(92,5):error : Assets file '\obj\project.assets.json' doesn'thave a target for '.NETCoreApp,Version=v1.1/ubuntu.16.10-x64'. Ensureyou have restored this project for TargetFramework='netcoreapp1.1' andRuntimeIdentifier='ubuntu.16.10-x64'.
我只想在 windows 8.1/windows7 上使用 VS2017 进行开发并部署到 ubuntu 16.10。我做错了什么?
更新2
我有 8 个项目正在解决。其中 3 个是 xUnit 测试。因此我们有 5 个项目。这 5 个中的 4 个是类库,1 个是我的网络应用程序。所有 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>
如何发布我的网络应用程序?
最佳答案
<TargetFramework>
(或 <TargetFrameworks>
当您想要有多个目标时,例如 net451
、一个或多个 netstandard1.x
等)。每<TargetFramework>
/<TargetFrameworks>
将创建一组程序集条目并位于 bin\Debug\<targetframeworkid>
内)。
当您想在 .NET Core 中使用不同的库(因为您使用的库仅适用于完整的 .NET Framework,例如 4.5.1)或从 .NET Core 中删除此功能(因为它不受支持)时,这非常有用。
它用于构建和 NuGet 恢复。即你不能使用 net451
.NET Core 项目中的唯一库(例如 netstandard 1.1
- 但您可以在 netstandard1.1
项目中使用 net451
)。
<RuntimeIdentifier>
/<RuntimeIdentifiers>
另一边主要用于NuGet。它告诉 NuGet 您需要哪些包。例如,如果您想要针对 Linux、Mac 和 Windows,某些程序集需要 native 库(例如加密。在 Windows 上将使用 CryptoAPI,但在 Linux 和 Mac 上您需要 OpenSSL)。这包括非托管 dll 和 *.so (Linux) 文件。
即<RuntimeIdentifiers>win7-x64;win7-x86;ubuntu.16.10-x64</RuntimeIdentifiers>
将为 win7(x64 和 x86)版本制作 nuget 恢复包,而 x64 仅适用于 ubuntu。这是必需的,因为当您在 Windows 上工作时,您也需要下载这些 native 库,因此您可以使用 dotnet publish
部署/打包它们。 。
这里有一个小问题:当您在 <TargetFramework>
中有完整的 .NET Framework 引用时或<TargetFrameworks>
,那么您必须指定单个 <RuntimeIdentifier>
(单数,而不是复数 <RuntimeIdentifiers>
),否则你会得到一个错误。
例如:
<PropertyGroup>
<TargetFrameworks>netstandard1.0;net451</TargetFrameworks>
<RuntimeIdentifiers>win7-x64;win7-x86;ubuntu.16.10-x64</RuntimeIdentifiers>
</PropertyGroup>
<!-- This entry will only be used for the .NET Framework 4.5.1 output -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net451'">
<RuntimeIdentifier>win7-x64</RuntimeIdentifier>
</PropertyGroup>
关于asp.net-core - .NET Core RuntimeIdentifier 与 TargetFramework,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43519690/
ASP.NET Core 项目创建了许多子目录,例如: bin\Debug\ne47\win81-x64 我发现其中一个可以用 secret AppendTargetFrameworkToOutput
有人可以解释一下csproj文件(VS2017)中这两个的用途吗: netstandard1.6 win7 我刚刚从 VS2015 迁移,现在无法发布我的 Web api,因为看起来我应该只使用一个目
可能是一个简单的问题,但很难找到相关信息。 我可以使用以下命令从 CLI 构建一个测试应用程序: dotnet publish -c Release -r rhel.7.2-x64 注意 -r 标志,
这是完整的错误: Your project file doesn't list 'win10' as a "RuntimeIdentifier". You should add 'win10' to
最后一次 Windows 更新破坏了我们的整个构建链,我有点不知道是什么原因造成的。 我有一个遗留项目,它是 VS 2017 解决方案,包含大量项目(winform、基于 Web 的项目、仅一些 We
我的解决方案是: Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 Visu
我是一名优秀的程序员,十分优秀!