【发布时间】:2016-03-09 13:30:49
【问题描述】:
我从我的项目中创建了一个 NuGet 包。包的输出目录是解决方案目录。我想将其输出到特定目录。我在 csproj 文件和 nuspec 文件中尝试了一个目标。没有工作。如何获取指定文件夹中生成的包?
在我的 .csproj 中:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
在我的 .nuspec 中:
<?xml version="1.0"?>
<package >
<metadata>
<id>MyPackage.dll</id>
<version>1.0.0</version>
<authors>me</authors>
<owners>me</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package description</description>
<releaseNotes>Summary of changes made in this release of the package.</releaseNotes>
<copyright>Copyright 2016</copyright>
<files>
<file src="bin\MyPackage.dll" target="C:\LocalPackageRepository" />
</files>
</metadata>
</package>
【问题讨论】:
-
您无法从 .nuspec 文件执行此操作。您可以创建 NuGet.Config 文件并为所有解决方案定义全局包目录。这是在 .nupkg 文件之外完成的,并存储在您的配置文件下或子目录中,该子目录是包含您的解决方案的所有目录的父目录。有关此功能,请参阅 NuGet documentation。
标签: .net nuget nuget-package