spp*_*c42 5 c# azure .net-core azure-pipelines
我有一个 .NetCore 3.1 命令行应用程序。在本地构建和发布时,使用以下命令行可以完全正常工作
dotnet publish -c dev -r win-x64 --self-contained true
在 Azure 管道中 - 我必须在dotnet restore使用上述命令进行发布之前执行此操作。在发布时,我必须添加额外的 param --no-restore,按照微软的建议,因为我有私人 nuget feed。
dotnet publish -c dev -r win-x64 --self-contained true --no-restore
大多数 dotnet 命令(包括构建、发布和测试)都包含隐式恢复步骤。即使您在前面的步骤中成功运行了 dotnet 恢复,这也会对经过身份验证的源失败,因为前面的步骤将清除它使用的凭据。
要解决此问题,请将 --no-restore 标志添加到参数文本框。
现在,管道的发布部分开始失败并出现错误 -
C:\Program Files\dotnet\sdk\3.1.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5):错误NETSDK1047:资产文件'MyProject\obj\project.assets.json ' 没有 '.NETCoreApp,Version=v3.1/win-x64' 的目标。确保恢复已运行并且您已将“netcoreapp3.1”包含在项目的 TargetFrameworks 中。您可能还需要在项目的运行时标识符中包含“win-x64”。
我不使用发布 xml,而是在命令行中指定如上所示的所有参数。我已经检查了 csproj 是否指定了目标框架
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release;dev;test;pre;prod</Configurations>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
需要任何关于这里可能出现问题的指示吗?
谢谢
请添加错误消息中提到的 RuntimeIdentifier:
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Configurations>Debug;Release;dev;test;pre;prod</Configurations>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
另请检查 PlatformTarget。
<PlatformTarget>AnyCPU</PlatformTarget>
Run Code Online (Sandbox Code Playgroud)
我猜本地机器的操作系统与构建代理不同。
| 归档时间: |
|
| 查看次数: |
2424 次 |
| 最近记录: |