dotnet / ILMerge

ILMerge is a static linker for .NET Assemblies.
MIT License
1.23k stars 170 forks source link

Install-Package : Package 'ilmerge 3.0.21' is not found #62

Closed gojimmypi closed 5 years ago

gojimmypi commented 5 years ago

I installed Visual Studio 2019 today, and tried to add the ILMerge tool using Install-Package ilmerge -Version 3.0.21 and received a Install-Package : Package 'ilmerge 3.0.21' is not found error.

image

Here's the full log of install attempt:

Each package is licensed to you by its owner. NuGet is not responsible for, nor does it grant any licenses to, third-party packages. Some packages may include dependencies which are governed by additional licenses. Follow the package source (feed) URL to determine any dependencies.

Package Manager Console Host Version 5.0.0.5917

Type 'get-help NuGet' to see all available NuGet commands.

PM> Install-Package ilmerge -Version 3.0.21

Attempting to gather dependency information for package 'ilmerge.3.0.21' with respect to project 'myprojectname', targeting '.NETFramework,Version=v4.6.2'
Install-Package : Package 'ilmerge 3.0.21' is not found in the following primary source(s): 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'. Please 
verify all your online package sources are available (OR) package id, version are specified correctly.
At line:1 char:1
+ Install-Package ilmerge -Version 3.0.21
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

Time Elapsed: 00:00:01.0570615
PM> 

There's this year-old open issue for NuGet: https://github.com/NuGet/Home/issues/1827 I cleared the cache as suggested, but no luck.

image

Does ILMerge work with Visual Studio 2019, or are there other ideas on how to make a single, stand-alone, portable exe file without needing all the other DLL's in the same directory?

lextm commented 5 years ago
Package 'ilmerge 3.0.21' is not found in the following primary source(s): 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'. Please 
verify all your online package sources are available (OR) package id, version are specified correctly.

Please re-read the error message, not the irrelevant GitHub thread.

You don't have a valid NuGet feed (like NuGet.org) for VS to locate ILMerge, and that's why it fails.

gojimmypi commented 5 years ago

Thank you. I did read the error message.

If I right-click on references, and select Manage NuGet Packages... it has this setting:

image

Is there someplace else that I need to tell Visual Studio to set the NuGet feed?

lextm commented 5 years ago

That goes far beyond the scope of ILMerge. But to get rid of VS's illusion, you can run the NuGet command line tool at the root of that project to see the effective feed list (based on messy NuGet configuration system),

nuget sources list
gojimmypi commented 5 years ago

At the package manager prompt? I get an error:

PM> nuget sources list
nuget : The term 'nuget' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a 
path was included, verify that the path is correct and try again.
At line:1 char:1
+ nuget sources list
+ ~~~~~
    + CategoryInfo          : ObjectNotFound: (nuget:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PM> 

I also tried just sources list

PM> sources list
sources : The term 'sources' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if 
a path was included, verify that the path is correct and try again.
At line:1 char:1
+ sources list
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (sources:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PM> 
gojimmypi commented 5 years ago

Ugh. There actually is a second place to set the package source. :/

In addition to the documented "right-click on references" mentioned above, there's another setting in the package manager console itself that I didn't notice. Apparently the default is the offline storage, regardless of settings in NuGet Package Manager.

image

And like most things, obvious when you know the answer, lol.

gojimmypi commented 5 years ago

I added some installation instructions to help others avoid this problem of two places to set the package source:

https://github.com/dotnet/ILMerge#installation

While I was there, also added some instructions for a batch file that does not use msbuild:

https://github.com/dotnet/ILMerge#to-run-ilmerge-in-a-batch-file