簡體   English   中英

在NuGet配置中使用環境變量?

[英]Use environment variable in NuGet config?

有沒有辦法在nuget配置中使用環境變量?

目前我被限制使用相對路徑,如下所示:

<configuration>
  <config>

    <add key="repositoryPath" value="..\..\teampackages" />
  </config>
</configuration>

但是擁有一個帶有絕對路徑的環境變量會非常方便。

如果在同一目錄中具有相應MyProject.nuspec文件的項目上運行nuget pack MyProject.csproj ,NuGet將使用$Property$格式的MSBuild屬性作為標記,其中Property是MSBuild屬性的名稱。 例如:

<?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>

在此示例中, $id$$version$$title$$author$$description$是NuGet自身根據項目文件和AssemblyVersion屬性(通常在AssemblyInfo.cs中找到)提供的特殊值。 但是, $OutputPath$是在公共目標中定義的MSBuild屬性。 您還可以使用$ MSBuildProjectDirectory $或任何其他標准屬性。

更多信息(“替換代幣”部分):

NuSpec參考

NuGet V3支持全局包文件夾,請參閱http://blog.nuget.org/20151008/NuGet-3-What-and-Why.html

NuGet V3.2支持全局NUGET_PACKAGES環境變量,以指定共享全局包文件夾的位置。 請參閱: https//docs.nuget.org/release-notes/nuget-3.2

也許其中一個可以幫助您解決問題。

我和你一樣有同樣的問題,這些功能看起來很有希望解決我遇到的實際問題。 NuGet 3.2僅適用於VS2015,我們在2015年還有其他一些問題,所以我還沒有嘗試過。

這適用於nuget 3.4及更高版本的標准%foo%環境變量引用: https//github.com/NuGet/Home/issues/1852

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM