Home:ALL Converter>Nuget pack existing build from csproj

Nuget pack existing build from csproj

Ask Time:2016-11-03T22:35:47         Author:aateeque

Json Formatter

In my CI build I have MSBuild which outputs Release builds into .\.output\_Build folder; in this case this folder has the exe that I want to package into a nupkg.

When I execute:

NuGet.exe pack -Version "0.1.0" -BasePath ".\.output\_Build" -OutputDirectory ".\.output\Packages\NuGet" ".\src\Project\Project.csproj" -Symbols -verbosity detailed -tool

The BasePath is the OutputPath folder in msbuild -OutputPath. I get:

Attempting to build package from 'Project.csproj'.
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.
NuGet.CommandLineException: Unable to find 'c:\project\src\.out\Debug\Project.exe'. Make sure the project has been built.
   at NuGet.CommandLine.ProjectFactory.BuildProject()
   at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath)
   at NuGet.CommandLine.PackCommand.BuildFromProjectFile(String path)
   at NuGet.CommandLine.PackCommand.BuildPackage(String path)
   at NuGet.CommandLine.PackCommand.ExecuteCommand()
   at NuGet.CommandLine.Command.ExecuteCommandAsync()
   at NuGet.CommandLine.Command.Execute()
   at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)

which seems to suggest that nuget read the OutputDirectory for the Debug configuration from the csproj and rightly failed to find anything to package up. I thought the -BasePath parameter would tell it where to look for the artifacts, but looks like that's not the case. How can I tell nuget to not follow the path in csproj when using csproj files for packaging? I have to use the csproj file for pack.

Author:aateeque,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/40404307/nuget-pack-existing-build-from-csproj
yy