AppVeyor Octopack - 失败的 GetAssemblyVersion
AppVeyor Octopack - Failing GetAssemblyVersion
我有一个 asp.net 核心 2.0 网络应用程序。我正在尝试使用 AppVeyor 构建带有 octopack 的 nuget 包,因此我们的章鱼服务器可以处理我们的部署过程。
我的 appveyor.yml 文件中列出了以下 steps 来执行 nuget 恢复和发布:
before_build:
- cmd: choco install octopustools
- cmd: nuget restore
- cmd: dotnet restore MyApp/MyApp.csproj
- cmd: dotnet publish MyApp/MyApp.csproj --output published-app --configuration=%CONFIGURATION%
- cmd: octo pack --id MyApp --version %APPVEYOR_BUILD_VERSION% --basePath MyApp/published-app
但是,当构建到达站点的 dotnet publish
时,它失败并出现以下错误:
dotnet publish MyApp/MyApp.csproj --output published-app --configuration=%CONFIGURATION%
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
SendGrid.NetCore -> C:\projects\MyApp\SendGrid.NetCore\bin\Release\netcoreapp2.0\SendGrid.NetCore.dll
MyApp -> C:\projects\MyApp\MyApp\bin\Release\netcoreapp2.0\MyApp.dll
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: The "GetAssemblyVersionInfo" task failed unexpectedly. [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: File name: 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: at OctoPack.Tasks.GetAssemblyVersionInfo.Execute() [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: [C:\projects\MyApp\MyApp\MyApp.csproj]
Command exited with code 1
我不确定为什么找不到 octopack 目标,因为我正在安装最新的 octopustools,目标应该基于引用项目。
更新: 我已将 RDP 连接到构建服务器,并且我能够从 powershell 控制台成功 运行 命令,并且它们成功了。以下是命令,以及 运行 执行这些命令的结果:
PS C:\projects\MyApp> dotnet publish MyApp/MyApp.csproj --output published-app --configuration=Release
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
SendGrid.NetCore -> C:\projects\MyApp\SendGrid.NetCore\bin\Release\netcoreapp2.0\SendGrid.NetCore.dll
MyApp -> C:\projects\MyApp\MyApp\bin\Release\netcoreapp2.0\MyApp.dll
MyApp -> C:\projects\MyApp\MyApp\published-app\
这是 octopack 步骤:
PS C:\projects\reportal> octo pack --id Reportal --version 2.2.2.2 --basePath Reportal/published-app
Octopus Deploy Command Line Tool, version 4.27.0
Packing Reportal version "2.2.2.2"...
Saving "Reportal.2.2.2.2.nupkg" to "C:\projects\reportal"...
Done.
*所以此时我迷失了为什么命令在 appveyor 运行s 上失败,但当我 运行 RDP 进入同一台机器时执行相同的命令时却没有。
更新 #2: 我现在意识到这些命令应该是 运行 作为 ps (powershell) 命令,没有标准的 cmd (bash) 命令。我将它们更正为
before_build:
- ps: echo buildNumber= $env:appveyor_build_number
- ps: echo configration= $env:configuration
- ps: choco install octopustools
- ps: choco install bower
- ps: nuget restore
- ps: dotnet restore MyApp/MyApp.csproj
- ps: dotnet publish MyApp/MyApp.csproj --output published-app --configuration $env:configuration
- ps: octo pack --id Reportal --version $env:appveyor_build_number --basePath MyApp/published-app
但是输出仍然返回关于上面显示的 octopack 目标的相同错误。这些命令正是我如何 运行 从 RDP 会话中正确构建和打包它们的方式。如此迷失为什么这个自动构建失败,但是手动 运行 从 RDP 工作相同的命令。
所以我收到了 Octopus Deploy 的回复,说 Octopack nuget 包没有更新以与 .net 核心项目一起使用。
删除包后,使用 octopus 工具构建和打包的效果很好。以下是适用于我的项目的完整步骤:
build_script:
- ps: choco install octopustools --no-progress
- ps: choco install bower --no-progress
- ps: dotnet restore
- ps: dotnet publish MyApp/MyApp.csproj --output published-app --configuration $env:configuration
- ps: octo pack --id MyCompany.MyApp --version $env:appveyor_build_version --basePath MyApp/published-app
我有一个 asp.net 核心 2.0 网络应用程序。我正在尝试使用 AppVeyor 构建带有 octopack 的 nuget 包,因此我们的章鱼服务器可以处理我们的部署过程。
我的 appveyor.yml 文件中列出了以下 steps 来执行 nuget 恢复和发布:
before_build:
- cmd: choco install octopustools
- cmd: nuget restore
- cmd: dotnet restore MyApp/MyApp.csproj
- cmd: dotnet publish MyApp/MyApp.csproj --output published-app --configuration=%CONFIGURATION%
- cmd: octo pack --id MyApp --version %APPVEYOR_BUILD_VERSION% --basePath MyApp/published-app
但是,当构建到达站点的 dotnet publish
时,它失败并出现以下错误:
dotnet publish MyApp/MyApp.csproj --output published-app --configuration=%CONFIGURATION%
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
SendGrid.NetCore -> C:\projects\MyApp\SendGrid.NetCore\bin\Release\netcoreapp2.0\SendGrid.NetCore.dll
MyApp -> C:\projects\MyApp\MyApp\bin\Release\netcoreapp2.0\MyApp.dll
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: The "GetAssemblyVersionInfo" task failed unexpectedly. [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: File name: 'Microsoft.Build.Utilities.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: at OctoPack.Tasks.GetAssemblyVersionInfo.Execute() [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack.6.3\build\OctoPack.targets(47,5): error MSB4018: [C:\projects\MyApp\MyApp\MyApp.csproj]
Command exited with code 1
我不确定为什么找不到 octopack 目标,因为我正在安装最新的 octopustools,目标应该基于引用项目。
更新: 我已将 RDP 连接到构建服务器,并且我能够从 powershell 控制台成功 运行 命令,并且它们成功了。以下是命令,以及 运行 执行这些命令的结果:
PS C:\projects\MyApp> dotnet publish MyApp/MyApp.csproj --output published-app --configuration=Release
Microsoft (R) Build Engine version 15.3.409.57025 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
SendGrid.NetCore -> C:\projects\MyApp\SendGrid.NetCore\bin\Release\netcoreapp2.0\SendGrid.NetCore.dll
MyApp -> C:\projects\MyApp\MyApp\bin\Release\netcoreapp2.0\MyApp.dll
MyApp -> C:\projects\MyApp\MyApp\published-app\
这是 octopack 步骤:
PS C:\projects\reportal> octo pack --id Reportal --version 2.2.2.2 --basePath Reportal/published-app
Octopus Deploy Command Line Tool, version 4.27.0
Packing Reportal version "2.2.2.2"...
Saving "Reportal.2.2.2.2.nupkg" to "C:\projects\reportal"...
Done.
*所以此时我迷失了为什么命令在 appveyor 运行s 上失败,但当我 运行 RDP 进入同一台机器时执行相同的命令时却没有。
更新 #2: 我现在意识到这些命令应该是 运行 作为 ps (powershell) 命令,没有标准的 cmd (bash) 命令。我将它们更正为
before_build:
- ps: echo buildNumber= $env:appveyor_build_number
- ps: echo configration= $env:configuration
- ps: choco install octopustools
- ps: choco install bower
- ps: nuget restore
- ps: dotnet restore MyApp/MyApp.csproj
- ps: dotnet publish MyApp/MyApp.csproj --output published-app --configuration $env:configuration
- ps: octo pack --id Reportal --version $env:appveyor_build_number --basePath MyApp/published-app
但是输出仍然返回关于上面显示的 octopack 目标的相同错误。这些命令正是我如何 运行 从 RDP 会话中正确构建和打包它们的方式。如此迷失为什么这个自动构建失败,但是手动 运行 从 RDP 工作相同的命令。
所以我收到了 Octopus Deploy 的回复,说 Octopack nuget 包没有更新以与 .net 核心项目一起使用。
删除包后,使用 octopus 工具构建和打包的效果很好。以下是适用于我的项目的完整步骤:
build_script:
- ps: choco install octopustools --no-progress
- ps: choco install bower --no-progress
- ps: dotnet restore
- ps: dotnet publish MyApp/MyApp.csproj --output published-app --configuration $env:configuration
- ps: octo pack --id MyCompany.MyApp --version $env:appveyor_build_version --basePath MyApp/published-app