This question might be a little outdated, but does 'init.ps1' scripts still works when installing a nupkg?
I was trying to use 'install.ps1' and 'uninstall.ps1', but after a little bit of research I've seen that those files stopped working with Visual Studio 2017 (which is the version of Visual I'm currently using), but I have not found any recent information about 'init.ps1' (being the most recent from 2017 or 2018).
My script is working correctly when executed by itself but seems like it's not getting called on the package install.
In the case that 'init.ps1' still works here's my '.nuspec' file, am I doing something wrong?:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>NugetTry</id>
<version>0.0.142</version>
<title>NugetTry</title>
<authors>rwpk9</authors>
<description>Description</description>
<copyright>Copyright © 2023</copyright>
<dependencies>
<group targetFramework=".NETFramework4.7.2">
<dependency id="EntityFramework" version="6.4.4" />
<dependency id="Microsoft.AspNet.Mvc.es" version="5.2.9" />
<dependency id="Newtonsoft.Json" version="13.0.2" />
</group>
</dependencies>
</metadata>
<files xmlns="">
<file src="init.ps1" target="." />
</files>
<powershell xmlns="">
<scripts>
<base><![CDATA[init.ps1]]></base>
</scripts>
</powershell>
</package>
My 'init.ps1' is at the same path as the '.nuspec'.
CodePudding user response:
The init.ps1
file needs to be in a tools/
directory, not the package root. So, the zip file's central directory record has a path of tools/init.ps1
CodePudding user response:
I think this no longer works.
I already put the init.ps1 to the tools directory and then configured the .nuspec, after that, package the package.
But if I install the package at the first time in the solution, I didn't see my powershell script run.
From the Nuget Product Team member:
https://github.com/NuGet/Home/issues/4318#issuecomment-343255043
powershel script is deprecated for package reference, we don't recommend people to use script in their packages.
I think this is deprecated.