NuGet / Home

Repo for NuGet Client issues
Other
1.49k stars 250 forks source link

Cannot package using NuGet pack, even with what appears to be a properly created packages.config #6129

Open sfatz opened 6 years ago

sfatz commented 6 years ago

Details about Problem: I am unable to successfully package a file using NuGet pack for a specific project on a specific computer. This used to work fine from my computer, but no longer does. I can still pack some projects, just not the specific one I am working on. I can completely delete the entire project, and pull it back down from our source control environment, and it still will not work. However, the same exact project pulled fresh from source control on a different machine works fine.

The specific error that I am getting is: Unable to find 'Microsoft.CodeAnalysis.Analyzers.1.1.0.nupkg'. Make sure the project has been built.

The particular nupkg file really doesn't matter. If I remove the reference to that package, then the next one in my packages.config file will cause the same error.

I have combed through the csproj file and my packages file to see if there is any difference between them and the projects that do build correctly, and I cannot find anything that appears to be wrong. The project itself builds just fine, and all of the requisite DLLs end up in the output folder. The nupkg files are all where they are supposed to be, as referenced in the csproj file (HintPath).

It will package if I do not add the parameter IncludeReferencedProjects.

NuGet product used: NuGet.exe

NuGet Version: 4.3.0.4406

dotnet.exe --version (if appropriate):

VS version (if appropriate): 2015 Enterprise

OS version (i.e. win10 v1607 (14393.321)): win10 v1703 (15063.674)

Worked before? If so, with which NuGet version: Yes it worked before, with nuget 4.3.0.4406

Detailed repro steps so we can see the same problem

  1. Run "c:\Nuget\NuGet pack NAMB.ESB.Messages.csproj -IncludeReferencedProjects"

  2. Receive the following output: Attempting to build package from 'NAMB.ESB.Messages.csproj'. MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin\amd64'. Packing files from 'D:\Development\NAMB\Service Bus\Shared\Dev\NAMB.ESB.Shared\NAMB.ESB.Messages\bin\Debug'. Using 'NAMB.ESB.Messages.nuspec' for metadata. Found packages.config. Using packages listed as dependencies Unable to find 'Microsoft.CodeAnalysis.Analyzers.1.1.0.nupkg'. Make sure the project has been built.

Verbose Logs

NuGet Version: 4.3.0.4406 Attempting to build package from 'NAMB.ESB.Messages.csproj'. MSBuild auto-detection: using msbuild version '14.0' from 'C:\Program Files (x86)\MSBuild\14.0\bin\amd64'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild. Packing files from 'D:\Development\NAMB\Service Bus\Shared\Dev\NAMB.ESB.Shared\NAMB.ESB.Messages\bin\Debug'. Using 'NAMB.ESB.Messages.nuspec' for metadata. Add file 'D:\Development\NAMB\Service Bus\Shared\Dev\NAMB.ESB.Shared\NAMB.ESB.Messages\bin\Debug\NAMB.ESB.Messages.dll' to package as 'lib\net452\NAMB.ESB.Messages.dll' Add file 'D:\Development\NAMB\Service Bus\Shared\Dev\NAMB.ESB.Shared\NAMB.ESB.Core\bin\Debug\NAMB.ESB.Core.dll' to package as 'lib\net452\NAMB.ESB.Core.dll' Add file 'D:\Development\NAMB\Service Bus\Shared\Dev\NAMB.ESB.Shared\NAMB.ESB.DomainContracts\bin\Debug\NAMB.ESB.DomainContracts.dll' to package as 'lib\net452\NAMB.ESB.DomainContracts.dll' Found packages.config. Using packages listed as dependencies Unable to find 'Microsoft.CodeAnalysis.Analyzers.1.1.0.nupkg'. Make sure the project has been built. NuGet.CommandLine.CommandLineException: Unable to find 'Microsoft.CodeAnalysis.Analyzers.1.1.0.nupkg'. Make sure the project has been built. at NuGet.CommandLine.ProjectFactory.AddDependencies(Dictionary2 packagesAndDependencies) at NuGet.CommandLine.ProjectFactory.RecursivelyApply(Action1 action, Object alreadyAppliedProjects) at NuGet.CommandLine.ProjectFactory.RecursivelyApply(Action`1 action) at NuGet.CommandLine.ProjectFactory.ProcessDependencies(PackageBuilder builder) 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)

emgarten commented 6 years ago

@sfatz has the project been restored? Does it build correctly? I would this error if pack is unable to find the dependency packages on disk.

sfatz commented 6 years ago

@emgarten The package does build correctly. I have in fact verified that the *.nupkg files are on the local disk.

henderjj commented 6 years ago

I have the same issue using VS2017 (15.4.5) to create the packages.config file and the VSTS NuGet Pack build task to build the NuGet package.

brooksca commented 6 years ago

I'm having the same issue as @henderjj except I'm using VS2017 15.5.7. The repo syncs with the repo in VSTS successfully, but in my NuGet Pack build step, I continually get an error that it can't find the project's dll and to make sure the project has been built.

sfatz commented 6 years ago

I found the issue that I was running into. I needed to revert to an older version of NuGet command line. When I did that, everything started working again.