NuGet Packager not allowing a prerelease dependency in VSTS - nuget-package

When NuGet creates my package I get an error for including a prerelease package and it gives me the following result:
C:\LR\Mms\Services\Mms\TaskAgentProvisioner\Tools\agents\2.109.1\externals\nuget\NuGet.exe pack "C:\a\1\s\Harvest.Auth\Harvest.Auth.csproj" -OutputDirectory "C:\a\1\s" -Properties Configuration=release -version 1.0.1
MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'.
Attempting to build package from 'Harvest.Auth.csproj'.
Packing files from 'C:\a\1\s\Harvest.Auth\bin\Release'.
Found packages.config. Using packages listed as dependencies
A stable release of a package should not have on a prerelease dependency. Either modify the version spec of dependency "Microsoft.Experimental.IdentityModel.Clients.ActiveDirectory (≥ 4.0.209160138-alpha)" or update the version field.
System.Exception: Unexpected exit code 1 returned from tool NuGet.exe
at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeToolCmdlet.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
PowerShell script completed with 1 errors.
I know that I need to mark my NuGet package as prerelease, however you can see in the first line it does not pickup my tag and version correctly which is 1.0.1-alpha, it only picks up 1.0.1.
I've also tried adding [assembly: AssemblyInformationalVersion("1.0.1-alpha")] per the NuGet documentation located here, however this didn't work either.
I was hoping there would be a command line to force it to create anyway, since we use it internally, and don't really care if it's pre-release or not. Here's the pack commands.
I should also note that we are using the NuGet packager that is part of VSTS.

Related

error MSB4086: A numeric comparison was attempted on "$(MSBuildVersion)" that evaluates to "" instead of a number

Trying to deploy the project with Azure Kudu (reading from a BitBucket repo) I get the following error in Deployment Center within Azure Portal...
This error happened with all the latest versions of Microsoft.Net.Compilers NuGet package. The only version that worked was 3.0.0 from 5 months ago.
Anyone knows what's the cause of this? Is Azure Kudu not yet updated?
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling .NET Web Application deployment.
MSBuild auto-detection: using msbuild version '14.0.23107.0 built by: D14REL' from 'D:\Program Files (x86)\MSBuild\14.0\Bin'.
Restoring NuGet package Microsoft.Net.Compilers.3.1.1.
GET https://api.nuget.org/v3-flatcontainer/microsoft.net.compilers/3.1.1/microsoft.net.compilers.3.1.1.nupkg
OK https://api.nuget.org/v3-flatcontainer/microsoft.net.compilers/3.1.1/microsoft.net.compilers.3.1.1.nupkg 937ms
Installing Microsoft.Net.Compilers 3.1.1.
Adding package 'Microsoft.Net.Compilers.3.1.1' to folder 'D:\home\site\repository\packages'
Added package 'Microsoft.Net.Compilers.3.1.1' to folder 'D:\home\site\repository\packages'
NuGet Config files used:
D:\local\UserProfile\AppData\Roaming\NuGet\NuGet.Config
Feeds used:
D:\home\.nuget\
https://api.nuget.org/v3/index.json
Installed:
1 package(s) to packages.config projects
D:\home\site\repository\packages\Microsoft.Net.Compilers.3.1.1\tools\Microsoft.Managed.Core.targets(63,60): error MSB4086: A numeric comparison was attempted on "$(MSBuildVersion)" that evaluates to "" instead of a number, in condition "$(MSBuildVersion) >= 16.1.0". [D:\home\site\repository\MyCompany\MyCompany.csproj]
Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\home\site\repository\MyCompany\MyCompany.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="D:\local\Temp\8d727f56aa60788";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="D:\home\site\repository\.\\"
An error has occurred during web site deployment.
\r\nD:\Program Files (x86)\SiteExtensions\Kudu\84.10807.4030\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"
### EDIT ###
I also opened an issue # Kudu GitHub repo.
I’ve had a similar issue with a kudu deployment and typescript versions. The basic issue seem to be that kudu is on its way out in favour of Azure DevOps so some dependencies of msbuild are becoming out of date. These are three options that might help you resolve the issue:
Switch to Azure DevOps - you’ll have access to various build agents and much more control over what they are capable of, but generally they’ll just be more up to date
Amend your build script - this is the script that kudu uses and you can customise it and then put it in source control, see this kudu doc for more info. Looks like you’re targeting msbuild 14 but I’m pretty sure 15 should be available and you can point your build script at this and/or make other tweaks
Process some of your build offline, ie before committing - this was my temporary solution with typescript, I was able to transpile to JavaScript and commit the js meaning I could disable typescript processing for kudu
It may also help to dig around in the targets file referenced in your log and trace back where the problem starts through the various msbuild conditions in that file. You can see all this by exploring via a command prompt in kudu.

Automate package version update with Continuous Integration in Bamboo

I have a query on how others accomplish this and what, if any, the best practices are. I have an application that comprises three packages and they are setup in Bamboo for CI/CD.
The issue I am experiencing is that of how to automate the update of the package version on each build, e.g. npm version patch to bump the package version.
What I would like to know is how other accomplish these, I have thought about manually running npm version patch but that is not ideal and would be prone to errors (eg. forgetting to run this). I had also thought of adding a step in Bamboo to run npm version patch during the build but Bamboo clones the repository with out remotes and there unable to commit the change, otherwise every build would be the same version and still no better off.
An example is that we have a package which is an Electron application and when the build runs generates an MSI and .yml file for the auto updater, without incrementing the version the MSI will always be the same version and therefore the auto update would not work.
So what are the strategies for automating the version of an npm package for each build? What do others do in similar situations?

How can I debug what targets a given NuGet package?

I'm trying to install Twilio Voice for Xamarin, and when I try to add it to my app, I get this error:
Attempting to gather dependency information for package 'Twilio.Voice.Xamarin.2.0.0-beta4-1' with respect to project 'voipphone', targeting 'Xamarin.iOS,Version=v1.0'
GET https://api.nuget.org/v3/registration1-gz/twilio.voice.xamarin/index.json
OK https://api.nuget.org/v3/registration1-gz/twilio.voice.xamarin/index.json 169ms
Total number of results gathered : 5
Gathering dependency information took 705.89 ms
Summary of time taken to gather dependencies per source :
https://api.nuget.org/v3/index.json - 171.21 ms
Attempting to resolve dependencies for package 'Twilio.Voice.Xamarin.2.0.0-beta4-1' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Twilio.Voice.Xamarin.2.0.0-beta4-1'
Resolved actions to install package 'Twilio.Voice.Xamarin.2.0.0-beta4-1'
Retrieving package 'Twilio.Voice.Xamarin 2.0.0-beta4-1' from 'nuget.org'.
Install failed. Rolling back...
Package 'Twilio.Voice.Xamarin.2.0.0-beta4-1' does not exist in project 'privatephone'
Package 'Twilio.Voice.Xamarin.2.0.0-beta4-1' does not exist in folder '/Users/Joe/Projects/voipapp/packages'
Executing nuget actions took 56.56 ms
Could not install package 'Twilio.Voice.Xamarin 2.0.0-beta4-1'. You are trying to
install this package into a project that targets 'Xamarin.iOS,Version=v1.0',
but the package does not contain any assembly references or content files that are compatible
with that framework. For more information, contact the package author.
Question
How can I manually download, inspect this NuGet package so I can see its intended use?
To download a Nuget Package, just go to this url: https://www.nuget.org/api/v2/package/Twilio.Voice.Xamarin/2.0.0-beta4-1
Once you download it, you can use something like 7zip to extract it and see its contents.
Looking inside it, it is designed for Xamarin.iOS and Android and I successfully installed it in my Xamarin.iOS app.

Azure build - [error]Unable to find version '' of package

Im trying to get a solution with Syncfusion to work.
But every time I try to deploy to Azure i get the following errors
##[error]Unable to find version '13.3.0.12' of package 'Syncfusion.AspNet.Mvc5'.
##[error]Unable to find version '13.3.0.12' of package 'Syncfusion.JavaScript'.
##[error]Unable to find version '13.3.0.12' of package 'Syncfusion.Web.Base45'.
##[error]Unable to find version '13.3.0.12' of package 'Syncfusion.Web.FileFormatsBase45'.
##[error]Unexpected exit code 1 returned from tool NuGet.exe
I tried creating a NuGet.config with the link to the syncfusion but dont work.
If i check the Packages folder i can see all the packages it says it cant find
Hope somone can help
Apparently you are using private NuGet feed, as these packages are not listed on the official NuGet feed, thus the error message.
Here is confirmation that these packages are not listed on the public NuGet feed:
http://www.nuget.org/packages?q=Syncfusion.AspNet.Mvc5
http://www.nuget.org/packages?q=Syncfusion.JavaScript
http://www.nuget.org/packages?q=Syncfusion.Web.Base45
http://www.nuget.org/packages?q=Syncfusion.Web.FileFormatsBase45
Which is also confirmed by the Syncfusion docs, which describe a custom feed for their packages: http://help.syncfusion.com/extension/syncfusion-nuget-packages/nuget-install-and-configuration
To enable restore of Syncfusion packages, check this SO question and its accepted answer on how can you include custom NuGet feeds to your Azure Web app deployment.

MSBuildTasks and NuGet - How can I restore MSBuild.Community.Tasks.dll?

I have a project which has a NuGet package called MSBuildTasks installed. It installs two files: MSBuild.Community.Tasks.targets and MSBuild.Community.Tasks.dll to the .build directory within the solution directory. This package reference has been added to the packages.config file in that project directory so that when I build the project (and with the NuGet package restore settings enabled) it will restore the package which is great because then I can distribute the source to other developers and build it on our build server without any missing files...
However, the problem is that when NuGet restores the package, it doesn't restore these two files to the expected location it was originally in when I first installed it with the Install-Package MSBuildTasks command, which was in to the $(SolutionDir)\.build directory. Instead, it has installed it to the $(SolutionDir)\packages\MSBuildTasks.1.4.0.78\tools directory, so now if I wish to include the MSBuild.Community.Tasks.targets file, I must reference this path absolutely in my .csproj or other .targets file. This presents a problem since the version number will undoubtedly change, requiring manual work to correct.
Is there some way that I can restore the MSBuildTasks .targets and .dll files to the original location of $(SolutionDir)\.build where it first installs to? The current behaviour of restoring in to the packages directory, while it makes sense for other packages, seems like a bug for this particular package since I will not be able to know the version number of the directory to include in my other .targets or .csproj files.
NuGet restore will only download files to the packages directory. It will not make any other modifications.
Looking at the MSBuildTasks NuGet package the files added to the $(SolutionDir)\.build are added by a PowerShell script. This PowerShell script will not be run when restoring the NuGet package.
You should add the $(SolutionDir)\.build to your source control repository.
With the newer versions 1.5+ the Nuget package doesn't install itself in the solution directory; this worked for me though:
<PropertyGroup>
<MSBuildCommunityTasksPath>$(USERPROFILE)\.nuget\packages\msbuildtasks\1.5.0.235\tools</MSBuildCommunityTasksPath>
</PropertyGroup>
It does involved adding the version, but if someone knows a way to remove having to update the version on the path when you update the package that would be awesome.

Resources