Attempt
Nuspec
<files>
<file src="https://raw.githubusercontent.com/030/chocolateyautomatic/master/common/Uninstall-ChocolateyZipPackage030.ps1" target="tools" />
</files>
Result
File is not added to tools directory
Running cpack indicates the following:
Calling 'C:\ProgramData\Chocolatey\chocolateyinstall\nuget.exe pack -NoPackageAnalysis
Attempting to build package from 'eclipse.nuspec'.
The given path's format is not supported.
Attempt two
<files>
<file src="path\to\chocolateyautomatic\common\Uninstall-ChocolateyZipPackage030.ps1" target="tools\Uninstall-ChocolateyZipPackage030.ps1" />
</files>
Result Two
The The given path's format is not supported. issue has been disappeared, but the Uninstall-ChocolateyZipPackage030.ps1 file is not added to the tools directory.
<files>
<file src="..\..\..\common\Uninstall-ChocolateyZipPackage030.ps1" target="tools\Uninstall-ChocolateyZipPackage030.ps1" />
<file src="tools\*" target="tools" />
</files>
adds all the files to the nupkg file.
Related
I have created a Nuspec file with the following files elements:
<files>
<file src="lib\" target="lib" />
<file src="tools\" target="tools" />
<file src="content\" target="content" />
<file src="other-stuff\" target="content" />
</files>
When I restore this Nuget package to any project, the contents of the other-stuff folder is added to the project (as expected).
Is there any way to ensure this content is placed on the filesystem, but not added to the project / solution? I don't want this content to show in Visual Studio.
There is no way to create a folder with no content in the nuspec file. However, you can definitely do this using a install.ps1 file. You can find many examples by searching for "nuget install.ps1" and utilizing powershell code to create a directory.
The .nuspec File Reference says that files without extensions can be selected in the following manner:
To include files without an extension, use the * or ** wildcards:
<file src="flags\**" target="flags" />
And, then also says that files can be rename in this manner:
<file src="ie\css\style.css" target="Content\css\ie.css" />
How can both this functions be combined to rename LICENSE to AssemblyName.license.txt? I have tried the following without any success:
<files>
<file src="../LICENSE*" target="./NHibernate.license.txt" />
-AND-
<file src="../LICENSE**" target="./NHibernate.license.txt" />
</files>
You cannot rename files using wildcard. To do what you would like to do, you will need to list out each file individually in the .nuspec file.
<file src="../LICENSE1" target="./1.license.txt" />
<file src="../LICENSE2" target="./2.license.txt" />
If you are frequently adding license files, you may wish to continue making a copy of all files before packing.
I am creating a nuget package definition to include a whole bunch of DLLs. Some of them are needed only at design time, so according to the Nuspec Reference I created a references section to specify which assemblies should be referenced by the project.
I also specified a list of files to be included. Some of these files being the libraries, one is a PowerShell script that gets executed during package installation and one is simply a content file that should be added to the project lateron.
These are the relevant sections of my nuspec file:
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<!-- Most of the metadata stuff left out for brevity -->
<dependencies />
<references>
<reference file="MyComponent.dll" />
<reference file="MyComponent.Data.dll" />
<reference file="MyComponent.Other.dll" />
</references>
</metadata>
<files>
<file src="MyPackage.install.ps1" target="tools\install.ps1" />
<file src="MyComponent.ReadMe.txt" target="ReadMe.txt" />
<file src="C:\Some\Path\MyComponent.*.dll" target="lib\net45" />
<file src="C:\Some\Path\MyComponent.*.xml" target="lib\net45" />
<file src="C:\Some\Other\Path\*.dll" target="lib\net45" />
</files>
</package>
Now here is my problem: The licenses.licx file does not get included in the project when the package is being installed. What must I change to achieve this?
Adding it to the references section does not work, because, well, it is no library...
I found out what was wrong. To include a file into the targeted project the file needs to be placed in a sub-folder named content in the package's folder structure:
The correct files section of the nuspec file would then look like this:
<files>
<!-- other files omitted for brevity -->
<file src="MyComponent.ReadMe.txt" target="content\ReadMe.txt" />
</files>
I have a nuget package with one dll that needs to be referenced and one dll that just needs to be included in the output of the program.
Relavent info from nuspec:
<references>
<reference file="dllA.dll" />
</references>
</metadata>
<files>
<file src="dllA.dll" target="lib" />
<file src="dllB.dll" target="content" />
</files>
I have been playing around with the install.ps1 file to try to modify the .csproj to add this section:
<Content Include="<path to dllB.dll">
<Link>dllB.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
I don't know how to get the path to dllB and I'm having trouble modifying the .csproj during the nuget package install with powershell.
I am creating a nuget package that besides other files contains also configuration files such as: f1.config, f2.config etc. These configuration files are in turn referenced in the web.config file.
As these configuration files may or may not exist in the project where this package would be installed, I have renamed them to f1.config.transform, f2.config.transform.
While the installation of the package runs flawlessly in all possible scenarios, uninstalling is not working as expected in one particular case. Namely, if let say the config file f2.config did not exist in the project before the installation, it will not be removed when uninstalling the package.
Any ideas?
EDIT: NuGet spec file
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>WCFServicesProxyPackage</id>
<version>1.0.3</version>
<title />
<authors>Shkelzen a. Saraqini</authors>
<owners>Shkelzen a. Saraqini</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>WCF services proxy package.</description>
<language>en-CA</language>
<references>
<reference file="WCFServices.Proxy.dll" />
</references>
</metadata>
<files>
<file src="content\config\system.serviceModel.behaviors.Local.config.transform" target="content\config\system.serviceModel.behaviors.Local.config.transform" />
<file src="content\config\system.serviceModel.behaviors.Production.config.transform" target="content\config\system.serviceModel.behaviors.Production.config.transform" />
<file src="content\config\system.serviceModel.behaviors.QA.config.transform" target="content\config\system.serviceModel.behaviors.QA.config.transform" />
<file src="content\config\system.serviceModel.bindings.Local.config.transform" target="content\config\system.serviceModel.bindings.Local.config.transform" />
<file src="content\config\system.serviceModel.bindings.Production.config.transform" target="content\config\system.serviceModel.bindings.Production.config.transform" />
<file src="content\config\system.serviceModel.bindings.QA.config.transform" target="content\config\system.serviceModel.bindings.QA.config.transform" />
<file src="content\config\system.serviceModel.client.Local.config.transform" target="content\config\system.serviceModel.client.Local.config.transform" />
<file src="content\config\system.serviceModel.client.Production.config.transform" target="content\config\system.serviceModel.client.Production.config.transform" />
<file src="content\config\system.serviceModel.client.QA.config.transform" target="content\config\system.serviceModel.client.QA.config.transform" />
<file src="content\Web.config.transform" target="content\Web.config.transform" />
<file src="lib\net40\WCFServices.Proxy.dll" target="lib\net40\WCFServices.Proxy.dll" />
</files>
</package>
How do you install/uninstall the config files? Could you share some PowerShell snippets from your scripts (assuming you're using PowerShell install.ps1/uninstall.ps1 scripts in your package)?
Maybe you can force the removal of the files: http://www.timvw.be/2011/10/18/force-the-removal-of-a-file-with-powershell/
Also, it is likely this functionality will be improved in the future, if and when XDT becomes OSS for NuGet to benefit from it.