Run install.ps1 when NOT installing in VisualStudio - visual-studio

I am looking for a way to execute a script when a nuget-Package is installed, but not in a VS solution or project.
I tried to include a install.ps1 in the tools folder, but it does not execute.
I thought it might be because I do not have any files in lib or content. So I included some dummy file into /content but it still does not execute.
So i changed it to an init.ps1 just to check but it still does not execute.
Now my guess is: the *.ps1 scripts only execute if I install the package into a VS solution/project. Is this correct? I did not find anything in regard in the documentation.
I am trying to install my package in a plain folder. No projects, no solutions, no VS.
Is there a way to make nuget execute any script in my case?

If you read the documentation here (Automatically Running PowerShell Scripts ) it mentions that those scripts are run in the context of a project or solution.
Most often install/uninstall action is add/remove references or files to/from the target project, so it actually makes no sence to run those without project context.

Related

Signalr for DotNetCore 2 packages missing all JavaScript

I'm trying to get Signalr from Nuget and have installed every package I can find, but can't seem to find the client JavaScript files that should be included. I've run the command from the package manager (in Visual Studio 2017)
npm install #aspnet/signalr
But alas, there is no /lib/signalr/signalr.js file anywhere. The Client stuff should be there. Where can I download this?
Found it! What the docs do not tell you is that the scripts are dumped into the following folder in the solution folder
node_modules\#aspnet\signalr\dist\browser
and there it was signalr.js (and the minimized version as well)
You create a folder called signalr under wwwroot/lib and place it there.

Uninstall nuget packages installed with nuget.exe

I was having trouble with nuget Visual Studio 2017 and wanted to test if it was our proxy server or not. I downloaded nuget.exe and dropped it at the root of my C drive. I executed nuget.exe install Microsoft.AspNetCore and it asked for my proxy server username and password. I supplied it, and it proceeded to create dozens of directories in C:\ with that package and all of it's dependencies (can I get a DOH!) Problem is, there's no uninstall in nuget.exe. The package manager in VS isn't available unless you have a solution open, and the package manager console (powershell) won't uninstall unless you have a solution open. Can I just clobber all those directories and their contents? Or will that just make things different and somehow worse:
Can I just clobber all those directories and their contents? Or will that just make things different and somehow worse
Yes, you can (If you confirm that you no longer need these packages).
According to the document install command (NuGet CLI):
The install command does not modify a project file or packages.config;
in this way it's similar to restore in that it only adds packages to
disk but does not change a project's dependencies.
When you use nuget.exe install some packages, it just download those packages to the disk and not change anything in the project, this is similar to some files you downloaded from the internet.
So, if you do not need those packages any more, you can just delete them from the disk manually.
Besides, there is an option delete command (NuGet CLI), which can be used to deletes or unlists a package from a package source. The exact behavior depends on the source. For local folders, for instance, the package is deleted; for nuget.org the package is unlisted. But it only delete the file .nupkg and will keep the folders and other files of other packages, like lib folder. If you want remove the package completely, just delete those packages manually.
Hope this helps.

Need PowerShell Script in NuGet to install selected DLLs from Package into a VS Project

Can anyone please explain me the detailed steps to include in a PowerShell script for installing selected DLLs from a package into a VS project, based on the References in a project (say from the .csproj file)?
Can anyone please explain me the detailed steps to include in a PowerShell script for installing selected DLLs from a package into a VS project, based on the References in a project (say from the .csproj file)?
As we know, there is a PowerShell script install.ps1 that can be included in the package, which is by convention named and located in tools folder.
Download a NuGet package, for example, Newtonsoft.Json.10.0.3. Open the install.ps1 file in the package with notepad, the scripts should begin with the following line:
param($installPath, $toolsPath, $package, $project)
$installPath path to where the project is installed
$toolsPath path to the extracted tools directory
$package information about the currently installing package
$project reference to the EnvDTE project the package is being installed into
See Running PowerShell scripts during NuGet package installation and removal for more detail.
Then after above scripts, you can find the below scripts, which used to install the dll from a package into a VS project:
$newRef = $project.Object.References.Add("PathToMyDLL")
Note: Install.ps will only be invoked if there is something in the \lib or \content folder, not for a "tools only" package.

TeamCity Missing Items in Work Directory Checkouts

I've been pouring over my set up for what feels like most of the day and I cannot figure out what I'm doing wrong.
I have 3 build configurations running on a single agent on my dev box. Checking out code from SVN.
I've got OctPack installed to create a couple of packages for deployment. In addition to this I've created a nuspec file to use in a NuGet Pack step. All of these bits work fine when testing.
The problem is that the nuspec file packages up some sql script files for deployment. Nothing fancy.
The problem is these sql files are disappearing from disk in the work folder. I get:
Cannot start build runner: Failed to find files to create packages matching: [src\database\SqlScriptsPackage.nuspec] under H:\TeamCity-Build\work\a1dbf81458fbab0a.
The entire database directory is empty despite all the contents being in SVN.
I've tried everything I can think of, including a forcing a clean checkout.
All the projects are using the same VCS Root setup to checkout "Automatically on server".
What could be ditching all these files?
Disable the [] Clean output directory checkbox on the NuGet Pack step.
I had this issue where I set the target directory for the Nuget pack step to be the same folder as the .csproj file I was building from.
With the tickbox ticked, it wiped the entire directory immediatly after checking it out.
I had a similar error when running on TeamCity:
Failed to find files to create packages matching: [myProject/myProject.nuspec]
under {C:\TeamCity\work\XXXXXXXXXX}
The key for us was that reading this message you could interpret it as it cannot find the files to go in the nuget package.
However, the issue was that it cannot find the .nuspec file.
So this then helped us look at the TeamCity working directory and what we were missing to get to the 'myProject' .nuspec path above.
Another thing to check is that you have the Octopack nuget package installed in your Visual Studio project. I forgot to do this with one of my projects and received the "Failed to find files to create packages matching" error. More information is available here:
http://help.octopusdeploy.com/discussions/questions/2304-teamcity-804-not-creating-nuget-packages

Batch Builds in Visual Studio 6 for VC++ project

In VS 2008 and VS 2010, one can easily create a solution and modify the "Solution Configuration". We can choose what configuration each project gets built in when we trigger a build at the solution level.
Is such a facility available in the Visual Studio 6.0?
In my experience:
when a configuration is chosen (form the list available) in VS6 for a VC++ project, the dependencies (which themselves have multiple configurations defined) get built in some random order. There is no way to control the configurations of dependencies at build time.
"Batch Build" does come close to this but is not as flexible for my purpose.
I have tried various options in the VS6.
Hope I am clear.
Here is a link on the MSDEV command line.
https://msdn.microsoft.com/en-us/library/aa699274(v=vs.60).aspx
There is a way to control the building of dependencies. Specify /NORECURSE and dependencies will not be built.
I use /REBUILD with /NORECURSE to keep the dependencies from getting built.
And I build each project one at a time inside the workspace in a bat file by doing a chdir to the subdirectory and calling MSDEV just for that subproject:
msdev myproject.dsp /MAKE "myproject - Win32 Debug" /REBUILD /NORECURSE > Build.log
Then I cd to the next project directory one at a time.
On a side note, I had difficulties for several years where NMAKE would not work for my specific tasks. Turns out that the PATH environment variable inside MSDEV (Visual Studio 6.0) is different from the PATH environment variable of a command shell you would run NMAKE on.
The Path used by the MSDEV shell is the %PATH% at the time Visual Studio 6 was installed. We use this and poke the registry as needed for MSDEV to get the correct path setup when switching revisions of our software; however this doesn't help update the %PATH%. The MSDEV path can be queried with a query script. I don't have my example handy.
That is why builds in MSDEV sometimes work when builds using the command line don't, as the path to DLLs differ, and any custom build steps that run .exe will not work outside of the MSDEV environment unless the path is updated.
I have a script somewhere that reads the queries the registry to extract the MSDEV path and update PATH of a shell so that batch scripts doing nmake will work as they would inside the MSDEV shell environment. The problem with the REGISTRY QUERY is that the return arguments differ with different flavors of Windows (XP/SERVER2003/...).
One thing I just discovered is that Incredibuild works with the old VS6.0 MSDEV IDE. This is a game changer. It distributes builds. I'm evaluating it now, but it might be useful to anyone waiting for long VS6.0 builds.

Resources