如何在使用TeamCity中的Nuget Restore时指定runtimeIdentifier和targetFramework值。

huangapple go评论60阅读模式
英文:

How to specify runtimeIdentifier and targetFramework values when using Nuget Restore in TeamCity

问题

我已经在TeamCity中设置了MSBuild来还原一个项目,指定了所需的runtimeIdentifiertargetFramework值,一切都还原得很顺利。

然而,当我尝试在TeamCity的NuGet安装程序中配置相同的还原时,尝试发布后会出现以下消息:

....obj\project.assets.json' doesn't have a target for 'net6.0/win-x64'. Ensure that restore has run and that you have included 'net6.0' in the TargetFrameworks for your project. You may also need to include 'win-x64' in your project's RuntimeIdentifiers.

我应该如何在TeamCity的NuGet Installer部分中指定这些参数以确保项目恢复时具有正确的目标?

NuGet是使用MSBuild还原的,所以我假设有一种方法可以做到这一点。通过“命令行参数”部分传递参数并不起作用。

英文:

I have TeamCity setup to restore a project using MSBuild, specifying the runtimeIdentifier and targetFramework values required, and everything restores smoothly.

However when I try to configure the same restore using the NuGet installer within team city, I get the following message after trying to publish:

....obj\project.assets.json' doesn't have a target for 'net6.0/win-x64'. Ensure that restore has run and that you have included 'net6.0' in the TargetFrameworks for your project. You may also need to include 'win-x64' in your project's RuntimeIdentifiers.

How and were do I specify these parameters in the NuGet Installer section of TeamCity, so that the project is restored with the correct targeting?

NuGet is restoring with MSBuild, so I'm presuming there is some way of doing this. Passing the params via the 'Command line parameters' section does not work.

如何在使用TeamCity中的Nuget Restore时指定runtimeIdentifier和targetFramework值。

答案1

得分: 1

你可以切换到 dotnet restore 并传递 --runtime 参数给它:

dotnet restore -r win-x64

目前没有找到关于它的具体文档,但似乎使用 使用 .NET Core 插件 并使用相应的命令应该能解决问题。

英文:

You can switch to dotnet restore and pass --runtime parameter to it:

dotnet restore -r win-x64

Could not find specific docs for it but it seems that using .NET Core plugin with corresponding command should do the trick.

答案2

得分: 0

如此看来,似乎不太可能。必须在.csproj文件中指定runtimeIdentifier和targetFramework:

<PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <Configurations>Debug;Release;Staging</Configurations>
</PropertyGroup>
英文:

So, it doesn't look possible. The runtimeIdentifier and targetFramework must be specified in the .csprof file:

&lt;PropertyGroup&gt;
    &lt;TargetFramework&gt;net6.0&lt;/TargetFramework&gt;
    &lt;RuntimeIdentifier&gt;win-x64&lt;/RuntimeIdentifier&gt;
    &lt;Configurations&gt;Debug;Release;Staging&lt;/Configurations&gt;
&lt;/PropertyGroup&gt;

huangapple
  • 本文由 发表于 2023年2月16日 18:18:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/75470797.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定