AppVeyor Octopack - Failing GetAssemblyVersion - asp.net-core

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.

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

Related

aspnet-codegenerator: No code generators available, Even after adding Microsoft.VisualStudio.Web.CodeGeneration.Design

Unable to generate scaffolding using aspnet-codegenerator, below is what I tried:
Created an ASP.Net RazorPages application using
dotnet new webapp
Did a dotnet build
Installed dotnet-aspnet-codegenerator using
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
Ran dotnet aspnet-codegenerator --help
It says: No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.
Added the package mentioned in step 4 using
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
Package added is:
<ItemGroup> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" /> </ItemGroup>
Again ran: dotnet build
Final-Step
Ran dotnet aspnet-codegenerator --help
Again it says: No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.
.Net core installed version: 3.1.401
Os: Ubuntu 20.04
This is already a few month old, but I ran into it recently for all my projects.
In case someone else lands on this page, the solution in my case(MAC OS), was to uninstall and reinstall dotnet-aspnet-codegenerator.
Run in terminal:
dotnet tool uninstall --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
I have same problem when upgrade from .net core 3.1.4 to 5.0.1.
My solution:
update global tools:
dotnet tool install --global dotnet-aspnet-codegenerator
dotnet tool update --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-ef
dotnet tool update --global dotnet-ef
add/update links to packages
dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.Design
Replace string netcoreapp3.1.4 to net5.0 in .csproj and launch.json files
Clear directories
bin
obj
Rebuild project
Finally run:
dotnet aspnet-codegenerator --help
If all fine it will show available generators.
The root cause of this problem has been described in this issue as the .NET code expecting a case-insensitive filesystem which fails on a Linux host.
A suggested workaround would be to temporarily mount you ~/.nuget directory on a vfat filesystem.
To do so create a dummy file holding the filesystem
dd if=/dev/zero of=/tmp/mynuget bs=1024k count=2000
mkfs.vfat /tmp/mynuget
and then mount it
sudo mount -o uid=myuser,gid=myuser -t vfat /tmp/mynuget /home/myuser/.nuget
and use it
dotnet restore
dotnet aspnet-codegenerator ...
I test your command,and when I do this dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4,I can get
and then Ran dotnet aspnet-codegenerator --help,I get the same message No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet with you,
but when I do the following,I can run without the message:
I think maybe the package is not added correctly,you can try to remove and add it again.
dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
I have found the SOLUTION to this issue:
The newest versions are giving some problems, so you will have to downgrade the version of the sdk to the 3.1.3 by writing this command on the terminal:
sudo apt install dotnet-sdk-3.1=3.1.301-1
After that you will need to install the following:
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.3
After that you will need to add the right Web.CodeGeneration.Design Package by writing this on the terminal:
sudo apt install dotnet-sdk-3.1=3.1.301-1
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.3
That has worked for me!!

cant Install [.net core] packages using visual studio code(dotnet cli)

I using the latest asp core 3.1 framework. I am trying to setup my database but there is an issue. I can't seem to install the following packages
dotnet tool install --global dotnet-ef
dotnet tool install --global dotnet-aspnet-codegenerator
dotnet add package Microsoft.EntityFrameworkCore.SQLite
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
I get the following errors. will appreciate it if any one can help with
a solution.
error NU1100: Unable to resolve 'dotnet-aspnet-codegenerator ' for '.NETCoreApp,Version=v3.1'.
error NU1100: Unable to resolve 'dotnet-aspnet-codegenerator ' for '.NETCoreApp,Version=v3.1/any'.
The tool package could not be restored.
Tool 'dotnet-aspnet-codegenerator' failed to install. This failure may have been caused by:
You are attempting to install a preview release and did not use the --version option to specify the version.
A package by this name was found, but it was not a .NET Core tool.
The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
You mistyped the name of the tool.
This happens when I try to install any of the packages.

ASP.Net Core 3.0 "dotnet bundle" exited with code 150

$ dn publish -f netcoreapp3.0 -c Release --no-restore --no-build src/Biz4x.Frontend.Web/
Microsoft (R) Build Engine version 16.3.0+0f4c62fea for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
bower font-awesome extra-resolution Unnecessary resolution: font-awesome#5.0.8
bower popper.js extra-resolution Unnecessary resolution: popper.js#v1.14.1
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.0.0-preview1-002111-00' was not found.
- The following frameworks were found:
3.0.0 at [/usr/share/dotnet-3.0.100/shared/Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
The .NET Core frameworks can be found at:
- https://aka.ms/dotnet-download
/usr/src/4xlabs/bz-frontend/src/Biz4x.Frontend.Web/Biz4x.Frontend.Web.csproj(89,5): error MSB3073: The command "dotnet bundle" exited with code 150.
Upgraded BundlerMinifier.Core to the latest version but to no avail!
<PackageReference Include="BundlerMinifier.Core" Version="3.0.415"/>
<DotNetCliToolReference Include="BundlerMinifier.Core" Version="3.0.415"/>
https://github.com/dotnet/cli/issues/12886

Missing required property 'OutputPath' for project type 'PackageReference'

I'm trying to run the following command thru Jenkins Pipeline
bat 'nuget restore mySolution.sln -MSBuildPath "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin"'
but i'm getting error saying
Invalid restore input. Missing required property 'OutputPath' for
project type 'PackageReference'. Input files: C:\Program Files
(x86)\Jenkins\workspace\My Project Build
Pipeline\myProject\myProject.csproj.
I tried
bat label: '', script: '"C:\\Package tools\\nuget.exe" restore "C:\\Program Files (x86)\\Jenkins\\workspace\\My Project Build Pipeline\\myProject\\myProject.csproj" -MSBuildPath "C:\\Program Files (x86)\\MSBuild\\14.0\\Bin"' // Restore packages.
I'm expecting all the NuGet packages to get installed as we 'Restore NuGet Packages' in Visual Studio.
Apparently you are using VS 2015 tools (MSBuild 14) and/or an older nuget.exe (< 4.0.0) to work on projects using the PackageReference way of referencing NuGet Packages. Use newer tools (Nuget 4+, VS / Build Tools 2017+) to fix this issue.
I fixed this problem by running the powershell command:
Install-Module VSSetup -Scope CurrentUser

Error: failed to retrieve information about - when trying to install SpaTemplates

I'm following this tutorial here
When I run this command
dotnet new --install Microsoft.AspNetCore.SpaTemplates::*
I get this error
Restoring packages for C:\Users\admin\.templateengine\dotnetcli\v1.0.4\scratch\restore.csproj...
C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Failed to retrieve information about
'Microsoft.NETCore.Targets' from remote source 'C:\Program Files\Microsoft SDKs\Service Fabric\packages\'.
[C:\Users\admin\.templateengine\dotnetcli\v1.0.4\scratch\restore.csproj]
How should I resolve this and how is this even linked to service fabric?
Find your local nuget.config with:
%appdata%/NuGet/NuGet.Config
And remove your local nuget package source.
I Hope it helps.