We use nuget as a mechanism for packing up our binaries however there is no .net code in our codebase. Essentially we have a bunch of scripts (.ps1
/.sh
/.sql
) that we want to package up and distribute. Nuget seems like a good mechanism for doing that. We use nuget's init.ps1
to install the package contents into the appropriate location in the destination.
Unfortunately init.ps1
only gets run when a package is consumed using tooling (more specifically, Visual Studio). We, however, simply use
nuget.exe install <package-name> -source "http://our.internal.nuget.feed" -solutiondirectory .
on the command line which means that we have to manually run init.ps1
thereafter.
Hence this feature request. Please can you add to nuget.exe
the ability to automatically run init.ps1
whenever nuget install
or nuget update
is issued?
NuGet.exe version: 3.5.0.1938
VS version (if appropriate): n/a
OS version: Win7
nuget install dh.PSP.SSE.Engine -source "http://builds/guestAuth/app/nuget/v1/FeedService.svc" -solutiondirectory .
Output, notice that init.ps1
(which does exist in the nuget package) did not get run:
Feeds used:
http://builds/guestAuth/app/nuget/v1/FeedService.svc
GET http://builds/guestAuth/app/nuget/v1/FeedService.svc/FindPackagesById()?id='dh.PSP.SSE.Engine'
OK http://builds/guestAuth/app/nuget/v1/FeedService.svc/FindPackagesById()?id='dh.PSP.SSE.Engine' 35ms
Attempting to gather dependency information for package 'dh.PSP.SSE.Engine.0.1.777' with respect to project '.\packages', targeting 'Any,Version=v0.0'
Gathering dependency information took 20.41 ms
Attempting to resolve dependencies for package 'dh.PSP.SSE.Engine.0.1.777' with
DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'dh.PSP.SSE.Engine.0.1.777'
Resolved actions to install package 'dh.PSP.SSE.Engine.0.1.777'
Retrieving package 'dh.PSP.SSE.Engine 0.1.777' from 'http://builds/guestAuth/app/nuget/v1/FeedService.svc'.
GET http://builds/guestAuth/app/nuget/v1/FeedService.svc/download/DhPspSse_DhPspSse1Commit/612129:id/dh.PSP.SSE.Engine.0.1.777.nupkg
OK http://builds/guestAuth/app/nuget/v1/FeedService.svc/download/DhPspSse_DhPspSse1Commit/612129:id/dh.PSP.SSE.Engine.0.1.777.nupkg 13ms
Installing dh.PSP.SSE.Engine 0.1.777.
Adding package 'dh.PSP.SSE.Engine.0.1.777' to folder 'C:\Users\jamiet\Downloads\nuget_test\packages'
Added package 'dh.PSP.SSE.Engine.0.1.777' to folder 'C:\Users\jamiet\Downloads\nuget_test\packages'
Successfully installed 'dh.PSP.SSE.Engine 0.1.777' to .\packages
Executing nuget actions took 49.28 sec
Putting request in backlog. Generally have been hesitant to do this. I wouldn't consider it likely.
Hi @rrelyea , thanks for the reply.
Generally have been hesitant to do this. I wouldn't consider it likely.
Could you explain why? TIA
What other automatic ways would you suggest then for a dev to get the required dependencies if he/she wants to set up an environment?
Dependency management should be doable by executing a command. With NuGet, if I give my project to some other dev, I have to instruct him to "Click here, click there.." to get the application into a buildable state.
Am I missing something?
powershel script is deprecated for package reference, we don't recommend people to use script in their packages. close this
@zhili1208 What about DotNetCliToolReference? If it's deprecated what should be the right way to do it?
If I create a dotnet cli extension package which is only a .cmd script how can I register this to the PATH on install if I don't have the install script?
Thanks!
@glucaci looks like you need Global tools, https://www.natemcmaster.com/blog/2018/02/02/dotnet-global-tool/
@zhili1208 Do you mean the system for executing scripts in a Nuget is depicted or specifically Powershell scripts? Also I can't see where Global tools provides the same functionality as the init.ps1 file executing every time the solution is loaded.
powershel script is deprecated for package reference, we don't recommend people to use script in their packages.
Well, you have broken everyone who has used/relied on PS scripts during Nuget installation.
What is the alternative? How do we migrate?
Please elaborate what you mean by "just use".
I need to install a chain of packages, each one of those may need to install own dependencies.
I can't expect users to know which order install.ps1 must be called and execute them.
install.ps1 are not longer executed in Nuget installed with PackageReference, the old way with packages.config is no longer supported going forward...
With ps1 support removed and contentFiles
being meant for read-only content is there really no way to some files to the package that user could modify?
I would like to create a package for game engine. This package should ship some resource files (shaders/materials/etc) which user will most likely modify. init.ps1
would have been ideal to extract these files to solution folder if resources directory is missing. Now there really is no way. Or am i mistaken?
Biggest issue is we need this in our pipe line and its a pain to get some with the rights to install global tools .
I had content files working however the offset is the project and need it in the root so used the Init.ps1 to basically copy files 2 levels up
Most helpful comment
Well, you have broken everyone who has used/relied on PS scripts during Nuget installation.
What is the alternative? How do we migrate?