gpt4 book ai didi

c# - 在 NuGet 配置中使用环境变量?

转载 作者:可可西里 更新时间:2023-11-01 07:47:15 25 4
gpt4 key购买 nike

有没有办法在 NuGet.Config 文件中使用环境变量?

目前我只能使用相对路径,如下:

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

但是如果有一个带有绝对路径的环境变量会非常方便。

最佳答案

如果您在同一目录中具有相应 MyProject.nuspec 文件的项目上运行 nuget pack MyProject.csproj,NuGet 将使 MSBuild 属性在$Property$ 格式,其中 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$ 或任何其他标准属性。

更多信息在这里(“替换 token ”部分):

NuSpec Reference

关于c# - 在 NuGet 配置中使用环境变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16861233/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com