AppVeyor Octopack - Failing GetAssemblyVersion

348 views Asked by At

I have a asp.net core 2.0 web app. I am attempting to use AppVeyor to build a nuget package with octopack, so our octopus server can handle our deployment process.

I have the following steps listed in my appveyor.yml file to do the nuget restore, and publish:

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

However, when the build reaches the dotnet publish of the site, it fails with the following error:

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\3.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\3.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\3.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\3.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\3.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\3.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\3.6.3\build\OctoPack.targets(47,5): error MSB4018:  [C:\projects\MyApp\MyApp\MyApp.csproj]
C:\Users\appveyor.nuget\packages\octopack\3.6.3\build\OctoPack.targets(47,5): error MSB4018:  [C:\projects\MyApp\MyApp\MyApp.csproj]
Command exited with code 1

I am unsure why octopack targets would not be found, since I am installing the latest octopustools, and the target should be based upon the referencing project.

UPDATE: I have RDP'd into the build server, and I was able to successfully run the commands from a powershell console, and they were successful. here are the commands, and results of running those commands:

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\

and here is the octopack step:

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.

*so at this time I am lost why the commands are failing on appveyor runs, but not when I run the same commands when RDP'd into the same machine.

UPDATE #2: I have now realized these commands should have been run as ps (powershell) commands, no standard cmd (bash) commands. I corrected them to

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

BUT the output still is returning the same error regarding the octopack target shown above. these command are EXACTLY how I am running them from the RDP session, which are building and packaging correctly. So lost on why this auto build fails, but manually running the same commands from the RDP works.

1

There are 1 answers

0
Nathan Tregillus On BEST ANSWER

So I got a response from Octopus Deploy that the Octopack nuget package is not been updated to work with .net core projects.

Once I removed the package, the build and package with the octopus tools worked great. here are the full steps that worked for my project:

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