microsoft / azure-pipelines-tasks

Tasks for Azure Pipelines
https://aka.ms/tfbuild
MIT License
3.42k stars 2.59k forks source link

NuGet Packager Fails When Using a Custom Path for NuGet.exe #3226

Closed montanehamilton closed 7 years ago

montanehamilton commented 7 years ago

Ran into the output below. As soon as I moved the path back to the default path for the task this problem went away. When running the same pack with the same version of NuGet that is at the custom path it all worked fine locally.

2016-12-09T17:56:13.8614284Z ##[section]Starting: NuGet Packager 2016-12-09T17:56:13.8634286Z ============================================================================== 2016-12-09T17:56:13.8634286Z Task : NuGet Packager 2016-12-09T17:56:13.8634286Z Description : Creates nupkg outputs from csproj or nuspec files 2016-12-09T17:56:13.8634286Z Version : 0.1.69 2016-12-09T17:56:13.8634286Z Author : Lawrence Gripper 2016-12-09T17:56:13.8634286Z Help : More Information 2016-12-09T17:56:13.8634286Z ============================================================================== 2016-12-09T17:56:13.8644280Z Preparing task execution handler. 2016-12-09T17:56:14.3734288Z Executing the powershell script: C:\a_tasks\NuGetPackager_333b11bd-d341-40d9-afcf-b32d5ce6f24b\0.1.69\NuGetPackager.ps1 2016-12-09T17:56:14.9454287Z C:\a\1\s\tools\nuget.exe pack "C:\a\1\s\Behavior\Behavior.csproj" -OutputDirectory "C:\a\1\s" -Properties Configuration=release -version 0.1.1-pullrequest1472-0009 2016-12-09T17:56:15.6336889Z Attempting to build package from 'Behavior.csproj'. 2016-12-09T17:56:15.6706888Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'. 2016-12-09T17:56:15.8497708Z Packing files from 'C:\a\1\s\Behavior\bin\Release'. 2016-12-09T17:56:15.9337708Z Using 'Behavior.nuspec' for metadata. 2016-12-09T17:56:15.9937707Z ##[error]Authors is required. 2016-12-09T17:56:15.9937707Z ##[error]Description is required. 2016-12-09T17:56:16.0137715Z ##[error]System.Exception: Unexpected exit code 1 returned from tool nuget.exe 2016-12-09T17:56:16.0137715Z at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeToolCmdlet.ProcessRecord() 2016-12-09T17:56:16.0137715Z at System.Management.Automation.CommandProcessor.ProcessRecord() 2016-12-09T17:56:16.0287690Z ##[error]PowerShell script completed with 1 errors. 2016-12-09T17:56:16.0287690Z ##[section]Finishing: NuGet Packager

zjrunner commented 7 years ago

How do you have this setup -- a template nuspec on disk? does it have authors and description in it? Are there multiple nuspec files in the folder or any other confusion that could happen there? Can you run with verbosity up in the build to see if your version of nuget prints more info (and what version of nuget are you using here?)

zjrunner commented 7 years ago

@montanehamilton -- any more info from the earlier questions? for pack, we do very little on top of nuget (not like we need to auth). Sounds like the nuspec is just missing data so wondering if you generate it or it is fully specified, etc.

montanehamilton commented 7 years ago

`<?xml version="1.0"?>

$id$ $version$ $id$ $author$ $author$ false $description$ Copyright 2016` Using the replacement tokens so the AssemblyInfo.cs has these. `[assembly: AssemblyTitle("Core")] [assembly: AssemblyDescription("Core")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Company")] [assembly: AssemblyProduct("Core")] [assembly: AssemblyCopyright("Copyright � Company 2016")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: AssemblyVersion("2.0.0.0")]` 2017-01-17T17:08:43.7218905Z ##[section]Starting: NuGet Packager 2017-01-17T17:08:43.7238896Z ============================================================================== 2017-01-17T17:08:43.7238896Z Task : NuGet Packager 2017-01-17T17:08:43.7238896Z Description : Creates nupkg outputs from csproj or nuspec files 2017-01-17T17:08:43.7238896Z Version : 0.1.69 2017-01-17T17:08:43.7238896Z Author : Lawrence Gripper 2017-01-17T17:08:43.7238896Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=627416) 2017-01-17T17:08:43.7238896Z ============================================================================== 2017-01-17T17:08:43.7248897Z Preparing task execution handler. 2017-01-17T17:08:44.1978911Z Executing the powershell script: C:\a\_tasks\NuGetPackager_333b11bd-d341-40d9-afcf-b32d5ce6f24b\0.1.69\NuGetPackager.ps1 2017-01-17T17:08:44.7738916Z C:\a\1\s\tools\nuget.exe pack "C:\a\1\s\Consumer\Consumer.csproj" -OutputDirectory "C:\a\1\s" -Properties Configuration=release -version 0.1.3-pullrequest1819-0009 2017-01-17T17:08:45.3388912Z Attempting to build package from 'Consumer.csproj'. 2017-01-17T17:08:45.3678907Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'. 2017-01-17T17:08:45.5318922Z Packing files from 'C:\a\1\s\Consumer\bin\Release'. 2017-01-17T17:08:45.6088918Z Using 'Consumer.nuspec' for metadata. 2017-01-17T17:08:45.6871463Z ##[error]Authors is required. 2017-01-17T17:08:45.6871463Z ##[error]Description is required. 2017-01-17T17:08:45.7021488Z ##[error]System.Exception: Unexpected exit code 1 returned from tool nuget.exe 2017-01-17T17:08:45.7021488Z at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeToolCmdlet.ProcessRecord() 2017-01-17T17:08:45.7021488Z at System.Management.Automation.CommandProcessor.ProcessRecord() 2017-01-17T17:08:45.7161470Z ##[error]PowerShell script completed with 1 errors. 2017-01-17T17:08:45.7161470Z ##[section]Finishing: NuGet Packager
montanehamilton commented 7 years ago

With "detailed" verbosity.

2017-01-17T17:27:26.4325799Z ##[section]Starting: NuGet Packager 2017-01-17T17:27:26.4385791Z ============================================================================== 2017-01-17T17:27:26.4385791Z Task : NuGet Packager 2017-01-17T17:27:26.4385791Z Description : Creates nupkg outputs from csproj or nuspec files 2017-01-17T17:27:26.4385791Z Version : 0.1.69 2017-01-17T17:27:26.4385791Z Author : Lawrence Gripper 2017-01-17T17:27:26.4385791Z Help : More Information 2017-01-17T17:27:26.4385791Z ============================================================================== 2017-01-17T17:27:26.4405803Z Preparing task execution handler. 2017-01-17T17:27:26.8975794Z Executing the powershell script: C:\a_tasks\NuGetPackager_333b11bd-d341-40d9-afcf-b32d5ce6f24b\0.1.69\NuGetPackager.ps1 2017-01-17T17:27:27.4845791Z C:\a\1\s\tools\nuget.exe pack "C:\a\1\s\Consumer\Consumer.csproj" -OutputDirectory "C:\a\1\s" -Properties Configuration=release -version 0.1.3-pullrequest1819-0009 -verbosity detailed 2017-01-17T17:27:28.0695802Z NuGet Version: 3.5.0.1938 2017-01-17T17:27:28.0725898Z Attempting to build package from 'Consumer.csproj'. 2017-01-17T17:27:28.1195830Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild. 2017-01-17T17:27:28.3595799Z Packing files from 'C:\a\1\s\Consumer\bin\Release'. 2017-01-17T17:27:28.4696717Z Using 'Consumer.nuspec' for metadata. 2017-01-17T17:27:28.5546720Z ##[error]System.Exception: Authors is required. 2017-01-17T17:27:28.5546720Z ##[error]Description is required. 2017-01-17T17:27:28.5546720Z ##[error] at NuGet.Packaging.Manifest.Validate(Manifest manifest) 2017-01-17T17:27:28.5546720Z ##[error] at NuGet.Packaging.Manifest.ReadFrom(Stream stream, Func`2 propertyProvider, Boolean validateSchema) 2017-01-17T17:27:28.5546720Z ##[error] at NuGet.CommandLine.ProjectFactory.ProcessNuspec(PackageBuilder builder, String basePath) 2017-01-17T17:27:28.5546720Z ##[error] at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath, NuGetVersion version, String suffix, Boolean buildIfNeeded) 2017-01-17T17:27:28.5546720Z ##[error] at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(String path) 2017-01-17T17:27:28.5546720Z ##[error] at NuGet.Commands.PackCommandRunner.BuildPackage(String path) 2017-01-17T17:27:28.5546720Z ##[error] at NuGet.Commands.PackCommandRunner.BuildPackage() 2017-01-17T17:27:28.5546720Z ##[error] at NuGet.CommandLine.PackCommand.ExecuteCommand() 2017-01-17T17:27:28.5546720Z ##[error] at NuGet.CommandLine.Command.ExecuteCommandAsync() 2017-01-17T17:27:28.5546720Z ##[error] at NuGet.CommandLine.Command.Execute() 2017-01-17T17:27:28.5546720Z ##[error] at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args) 2017-01-17T17:27:28.5676719Z ##[error]System.Exception: Unexpected exit code 1 returned from tool nuget.exe 2017-01-17T17:27:28.5676719Z at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeToolCmdlet.ProcessRecord() 2017-01-17T17:27:28.5686720Z at System.Management.Automation.CommandProcessor.ProcessRecord() 2017-01-17T17:27:28.5826720Z ##[error]PowerShell script completed with 1 errors. 2017-01-17T17:27:28.5826720Z ##[section]Finishing: NuGet Packager

montanehamilton commented 7 years ago

Running similar pack command locally is working. @zjrunner

Going back to built in version of NuGet.exe yields:

2017-01-17T18:34:58.0103687Z ##[section]Starting: NuGet Packager 2017-01-17T18:34:58.0113690Z ============================================================================== 2017-01-17T18:34:58.0113690Z Task : NuGet Packager 2017-01-17T18:34:58.0123686Z Description : Creates nupkg outputs from csproj or nuspec files 2017-01-17T18:34:58.0123686Z Version : 0.1.69 2017-01-17T18:34:58.0123686Z Author : Lawrence Gripper 2017-01-17T18:34:58.0123686Z Help : More Information 2017-01-17T18:34:58.0123686Z ============================================================================== 2017-01-17T18:34:58.0133684Z Preparing task execution handler. 2017-01-17T18:34:58.4653698Z Executing the powershell script: C:\a_tasks\NuGetPackager_333b11bd-d341-40d9-afcf-b32d5ce6f24b\0.1.69\NuGetPackager.ps1 2017-01-17T18:34:59.0763705Z C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agents\2.110.0\externals\nuget\NuGet.exe pack "C:\a\1\s\Consumer\Consumer.csproj" -OutputDirectory "C:\a\1\s" -Properties Configuration=release -version 0.1.3-pullrequest1819-0010 -verbosity detailed 2017-01-17T18:34:59.6973706Z MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild. 2017-01-17T18:34:59.6983705Z Attempting to build package from 'Consumer.csproj'. 2017-01-17T18:34:59.8903704Z Packing files from 'C:\a\1\s\Consumer\bin\Release'. 2017-01-17T18:35:00.0443705Z Using 'Consumer.nuspec' for metadata. 2017-01-17T18:35:00.1483699Z WARNING: File 'C:\a\1\s\Consumer\bin\Release\Cireson.ContentLibrary.Consumer.dll' is not added because the package already contains file 'lib\net46\Cireson.ContentLibrary.Consumer.dll' 2017-01-17T18:35:00.2930794Z ##[error]System.InvalidOperationException: 'AutoMapper' already has a dependency defined for 'NETStandard.Library'. 2017-01-17T18:35:00.2930794Z ##[error] at NuGet.Manifest.ValidateDependencySets(IPackageMetadata metadata) 2017-01-17T18:35:00.2930794Z ##[error] at NuGet.Manifest.Validate(Manifest manifest) 2017-01-17T18:35:00.2930794Z ##[error] at NuGet.Manifest.ReadFrom(Stream stream, IPropertyProvider propertyProvider, Boolean validateSchema) 2017-01-17T18:35:00.2930794Z ##[error] at NuGet.LocalPackage.ReadManifest(Stream manifestStream) 2017-01-17T18:35:00.2930794Z ##[error] at NuGet.OptimizedZipPackage.EnsureManifest() 2017-01-17T18:35:00.2930794Z ##[error] at NuGet.OptimizedZipPackage..ctor(IFileSystem fileSystem, String packagePath, IFileSystem expandedFileSystem) 2017-01-17T18:35:00.2940790Z ##[error] at NuGet.SharedPackageRepository.OpenPackage(String path) 2017-01-17T18:35:00.2940790Z ##[error] at NuGet.LocalPackageRepository.GetPackage(Func2 openPackage, String path) 2017-01-17T18:35:00.2940790Z ##[error] at NuGet.LocalPackageRepository.<>c__DisplayClass13.<FindPackage>b__f(String path) 2017-01-17T18:35:00.2940790Z ##[error] at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() 2017-01-17T18:35:00.2940790Z ##[error] at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() 2017-01-17T18:35:00.2940790Z ##[error] at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source) 2017-01-17T18:35:00.2940790Z ##[error] at NuGet.LocalPackageRepository.FindPackage(Func2 openPackage, String packageId, SemanticVersion version) 2017-01-17T18:35:00.2940790Z ##[error] at NuGet.LocalPackageRepository.FindPackage(String packageId, SemanticVersion version) 2017-01-17T18:35:00.2940790Z ##[error] at NuGet.SharedPackageRepository.FindPackage(String packageId, SemanticVersion version) 2017-01-17T18:35:00.2940790Z ##[error] at NuGet.PackageRepositoryExtensions.FindPackage(IPackageRepository repository, String packageId, SemanticVersion version, IPackageConstraintProvider constraintProvider, Boolean allowPrereleaseVersions, Boolean allowUnlisted) 2017-01-17T18:35:00.2940790Z ##[error] at NuGet.CommandLine.ProjectFactory.<>c__DisplayClass92_0.<AddFiles>b__0(PackageReference reference) 2017-01-17T18:35:00.2940790Z ##[error] at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() 2017-01-17T18:35:00.2940790Z ##[error] at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() 2017-01-17T18:35:00.2950789Z ##[error] at System.Linq.Enumerable.<SelectManyIterator>d__162.MoveNext() 2017-01-17T18:35:00.2950789Z ##[error] at System.Collections.Generic.List1..ctor(IEnumerable1 collection) 2017-01-17T18:35:00.2950789Z ##[error] at System.Linq.Enumerable.ToList[TSource](IEnumerable1 source) 2017-01-17T18:35:00.2950789Z ##[error] at NuGet.CommandLine.ProjectFactory.AddFiles(PackageBuilder builder, String itemType, String targetFolder) 2017-01-17T18:35:00.2950789Z ##[error] at NuGet.CommandLine.ProjectFactory.<>c__DisplayClass56_0.<CreateBuilder>b__1(ProjectFactory p) 2017-01-17T18:35:00.2950789Z ##[error] at NuGet.CommandLine.ProjectFactory.ApplyAction(Action1 action) 2017-01-17T18:35:00.2950789Z ##[error] at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath) 2017-01-17T18:35:00.2950789Z ##[error] at NuGet.CommandLine.PackCommand.BuildFromProjectFile(String path) 2017-01-17T18:35:00.2950789Z ##[error] at NuGet.CommandLine.PackCommand.BuildPackage(String path) 2017-01-17T18:35:00.2950789Z ##[error] at NuGet.CommandLine.PackCommand.ExecuteCommand() 2017-01-17T18:35:00.2950789Z ##[error] at NuGet.CommandLine.Command.ExecuteCommandAsync() 2017-01-17T18:35:00.2950789Z ##[error] at NuGet.CommandLine.Command.Execute() 2017-01-17T18:35:00.2950789Z ##[error] at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args) 2017-01-17T18:35:00.3140780Z ##[error]System.Exception: Unexpected exit code 1 returned from tool NuGet.exe 2017-01-17T18:35:00.3140780Z at Microsoft.TeamFoundation.DistributedTask.Task.Internal.InvokeToolCmdlet.ProcessRecord() 2017-01-17T18:35:00.3140780Z at System.Management.Automation.CommandProcessor.ProcessRecord() 2017-01-17T18:35:00.3280769Z ##[error]PowerShell script completed with 1 errors. 2017-01-17T18:35:00.3290774Z ##[section]Finishing: NuGet Packager

zjrunner commented 7 years ago

Ok, so 3.5 isn't filling in the tokens, only in the vsts build task flow, but earlier versions can't be used because you need dotnetstandard. We'll try to get a repro over here, but can you confirm when you run this locally you're using the exact same commandline and you have the template nuspec (nothing cached so it must do token replacement)? nuget.exe pack "C:\a\1\s\Consumer\Consumer.csproj" -OutputDirectory "C:\a\1\s" -Properties Configuration=release -version 0.1.3-pullrequest1819-0009 -verbosity detailed

montanehamilton commented 7 years ago

Was using older version locally, 3.5.0.1938 fails locally as well. @zjrunner

zjrunner commented 7 years ago

Ah, I'll see if I can get the nuget team involved to comment.

rohit21agrawal commented 7 years ago

am looking into this, will update this thread when i have more info.

rohit21agrawal commented 7 years ago

this seems to be working for me . Sample project attached ClassLibrary2.zip

Command line used : nuget pack ClassLibrary2.csproj

NuGet version : 3.5.0.1938

If this is still an issue for you, please attach a minimal repro, and file a bug on https://github.com/nuget/home/issues for more visibility

montanehamilton commented 7 years ago

@rohit21agrawal I'm running into it again but about to leave town and will have to slim down the project next week for you. Just to confirm, if targeting a csproj to package and there is a nuspec in the directory with tokens they should be replaced no problem?

On the other hand targeting a nuspec directly with tokens will fail, by design, to replace tokens right?

rohit21agrawal commented 7 years ago

@montanehamilton a couple things to note here:

1) Make sure that you dont change the name of your nuget executable as this may cause errors related to metadata extraction . (Known issue : https://github.com/NuGet/Home/issues/3146 )

2) Token substitution only works if nuget can extract assembly metadata - this is only possible if you pack using a csproj file and there is a corresponding nuspec file present. However, assemblies targeting netstandard are known to have issues with metadata extraction. There are known workarounds ( See : https://github.com/NuGet/Home/issues/4052)

3) If packing using a nuspec file solely, token substitution will work for properties that are passed via tha command line using the -Properties switch.

Let me know if you have any more questions.

infin8x commented 7 years ago

Closing this out since it's old - please respond if you're still having issues.