While building my C++ application, the postbuild event contains the following command:
NuGet pack "$(ProjectPath)"
-OutputDirectory "$(TargetDir)NuGet"
-IncludeReferencedProjects
-Properties Configuration=$(ConfigurationName)
First this failed due to error code 9009, meaning it didn't find the program "NuGet.exe". I have downloaded that program on my PC, and now this is the error message I get:
C:\Program Files\Microsoft Visual Studio\2022\Professional>NuGet pack ...
Attempting to build package from '....csproj'.
MSBuild auto-detection: using msbuild version '17.14.23.42201' from 'C:\Program Files\Microsoft Visual Studio\2022\Professional\MSBuild\Current\Bin'.
Packing files from 'C:\...\bin\Debug'.
Using '....ExternalInterface.nuspec' for metadata.
The user name or password is incorrect.
This latter is confirmed by Developer Command Prompt (I get there the same error message).
I have the impression "NuGet.exe" is configured somewhere in order to get username/password from... where?
Here is where I stored "NuGet.exe":
C:\Program Files\NuGet>dir /S /B
C:\Program Files\NuGet\nuget.exe
What can I do now? Should I re-install "NuGet.exe" in some official way?
P.s. by adding detailed verbosity to the "NuGet" command, this is the extra information I get:
The user name or password is incorrect.
System.IO.IOException: The user name or password is incorrect.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileSystemEnumerableIterator`1.CommonInit()
at System.IO.FileSystemEnumerableIterator`1..ctor(String path, String originalUserPath, String searchPattern, SearchOption searchOption, SearchResultHandler`1 resultHandler, Boolean checkHost)
at System.IO.Directory.GetFiles(String path, String searchPattern, SearchOption searchOption)
at NuGet.Common.PathResolver.PerformWildcardSearch(String basePath, String searchPath, Boolean includeEmptyDirectories, String& normalizedBasePath)
at NuGet.Packaging.PackageBuilder.ResolveSearchPattern(String basePath, String searchPath, String targetPath, Boolean includeEmptyDirectories)
at NuGet.Packaging.PackageBuilder.AddFiles(String basePath, String source, String destination, String exclude)
at NuGet.Packaging.PackageBuilder.PopulateFiles(String basePath, IEnumerable`1 files)
at NuGet.CommandLine.ProjectFactory.ProcessNuspec(PackageBuilder builder, String basePath)
at NuGet.CommandLine.ProjectFactory.CreateBuilder(String basePath, NuGetVersion version, String suffix, Boolean buildIfNeeded, PackageBuilder builder)
at NuGet.Commands.PackCommandRunner.BuildFromProjectFile(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, IEnvironmentVariableReader environmentVariableReader)
P.s.2: hereby the contents of the corresponding .nuspec file:
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>$id$</id>
<version>9.10.1680.1</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<icon>Frameworks.png</icon>
<description>Project description</description>
<releaseNotes></releaseNotes>
<copyright>$copyright$</copyright>
<tags></tags>
<dependencies>
<group targetFramework=".NETFramework4.8" />
</dependencies>
</metadata>
<files>
<file src="\\<FileServer>\Packages\NuGet\icons\" />
</files>
</package>
Some thoughts:
- By adding "detailed" verbosity, I now know that there is a problem while resolving some path.
- It would be very useful to have actual argument values instead of the general function description, as in the following lines:
2.1. Replaceat System.IO.Directory.GetFiles(String path
2.2. ... byat System.IO.Directory.GetFiles("C:\..." NuGet Pack /?reveals the-NonInteractiveswitch. In my opinion this means thatNuGet Packcan be used in an interactive way too and this seems to be the default. As a result I expect the question for a username/password. As this question does not appear, I suspect that information to be present in some file, but where? (The.nuspecfile seems not to contain any such information and the files, referred to, seem only to be*.icoand*.pngfiles)
-Verbosity detailedargument to make build log more informative..nuspecfile, maybe this might shed some light on the situation.C:\Program Files\Microsoft Visual Studio\2022\Professional?cd "$(ProjectDir)"andcd(that latter command for verifying the current directory indeed changed into the project directory).NuGet Packcommand).