【发布时间】:2020-01-30 15:43:28
【问题描述】:
我在尝试通过 Team City 构建和发布 MSBuild 时遇到了问题。收到的错误信息如下:
C:\Program Files\dotnet\sdk\2.2.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(208, 5): error NETSDK1047: Assets file 'F:\TeamCity\buildAgent\work\9f1e0cb4e5e5076f\myproject\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.2/win-x64'. Ensure that restore has run and that you have included 'netcoreapp2.2' in the TargetFrameworks for your project. You may also need to include 'win-x64' in your project's RuntimeIdentifiers.
我原以为将以下参数传递给 MSBuild 应该可以解决问题。
/p:TargetFramework=netcoreapp2.2 /p:Runtimeidentifier=win-x64
然而事实并非如此。
我可以在 Visual Studio 中构建/发布项目,但不能通过 Team City 构建代理。
为了让构建代理构建/发布,我必须在项目 .csproj 文件中声明运行时标识符:
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
在我看来,Team City 忽略了 MSBuild 参数、我的参数不正确,或者 Visual Studio 正在执行我不知道的附加步骤,以在发布时声明运行时标识符(通过 WebDeploy)。
我显然已经解决了我遇到的问题,但这似乎不是“正确”的做法。我错过了什么?
谢谢,
【问题讨论】:
标签: visual-studio asp.net-core msbuild teamcity