Is there a way to use an environment variable in NuGet.Config
file?
Currently I am constrained to using relative path, as follows:
<configuration>
<config>
<add key="repositoryPath" value="..\..\teampackages" />
</config>
</configuration>
But would be really handy to have an environment variable with absolute path instead.
Click “Advanced System Settings” then click the “Environment Variables” button located within the Advanced tab. From here double-click the PATH variable in the top panel and create a new entry by adding the path to the directory that contains your NuGet.exe file (in this instance it's C:/NuGet/).
To manage your package sources, select the Settings icon or select Tools > Options. In the Options window, expand the NuGet Package Manager node and select Package Sources. To add a source, select +, edit the Name, enter the URL or path in Source, and then select Update.
Abstract. The NuGet Visual Studio extension, the NuGet Package Manager Console, and the NuGet command-line tool all make use of the NuGet configuration file, which by default is located under %AppData%\NuGet\NuGet.
If you run nuget pack MyProject.csproj
on a project with a corresponding MyProject.nuspec
file in the same directory, NuGet will make the MSBuild properties available as tokens in the format $Property$
, where Property
is the name of the MSBuild property. For example:
<?xml version="1.0"?>
<package >
<metadata>
<id>$id$</id>
<version>$version$</version>
<title>$title$</title>
<authors>$author$</authors>
<owners>$author$</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>$description$</description>
<copyright>Copyright 2013</copyright>
</metadata>
<files>
<file src="$OutputPath$MyProject.pdb" target="lib\net40"/>
</files>
</package>
In this example $id$
, $version$
, $title$
, $author$
and $description$
are special values provided by NuGet itself based on the project file and AssemblyVersion attribute (normally found in AssemblyInfo.cs). However, $OutputPath$
is an MSBuild property defined in the common targets. You could also use $MSBuildProjectDirectory$ or any other standard property.
More info here ("Replacement Tokens" section):
NuSpec Reference
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With