我知道以前有人问过这个问题,但是由于某种原因,我找到的答案对我不起作用。
请让我描述一下我的问题。
我正在使用 Visual Studio 2012 和 TFS 2012
在我的组织中,我们有几个应用程序,其中一些公开了共享 DLL,我们希望将它们作为 Nuget 包发布到私有 Nuget 服务器中
因此,在其中一个项目中,我将以下代码添加到csproj文件中
<Target Name="AfterBuild">
<Exec ContinueOnError="false" WorkingDirectory="$(OutDir)" Command=""$(SolutionDir).nuget\nuget.exe" pack "$(ProjectPath)" -Exclude "*.nlp" -IncludeReferencedProjects -NonInteractive -Verbosity detailed -NoDefaultExcludes -Properties Configuration="$(Configuration)";Platform="$(Platform)"" />
</Target>
在与我的项目文件相同的级别上,我有代表我的 Nuget 元数据的nuspec文件,它看起来像:
<?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>
<releaseNotes>Super dooper cool framework</releaseNotes>
<copyright>$copyright$</copyright>
<tags>Some My Company framework</tags>
</metadata>
</package>
这在本地工作得非常好,每次我构建我的项目时,它都会按照我想要的方式为我创建一个 Nuget 包。
但是在构建服务器上它不起作用,我尝试了几种组合,我一直收到同样的错误:
"D:\Builds\23\someCompany\somebuilddefinition\Sources\.nuget\nuget.exe" pack "D:\Builds\23\someCompany\somebuilddefinition\Sources\NugetLibrary\NugetLibrary.csproj" -Exclude "*.nlp" -IncludeReferencedProjects -NonInteractive -Verbosity detailed -NoDefaultExcludes -Properties Configuration="Release";Platform="AnyCPU"
Attempting to build package from 'NugetLibrary.csproj'.
NuGet.CommandLineException: Unable to find 'D:\Builds\23\someCompany\somebuilddefinition\Sources\NugetLibrary\bin\Release\NugetLibrary.dll'. Make sure the project has been built.
at NuGet.Commands.ProjectFactory.BuildProject()
at NuGet.Commands.ProjectFactory.CreateBuilder(String basePath)
at NuGet.Commands.PackCommand.BuildFromProjectFile(String path)
at NuGet.Commands.PackCommand.BuildPackage(String path)
at NuGet.Commands.PackCommand.ExecuteCommand()
at NuGet.Commands.Command.Execute()
at NuGet.Program.Main(String[] args)
这是可以理解的,因为在构建服务器上,输出路径被覆盖,它指向:
D:\Builds\23\someCompany\somebuilddefinition\Binaries
所以我尝试了几种组合,但我找不到强制 Nuget 使用我的自定义路径来查找构建过程生成的 DLL 的方法。
这些是我迄今为止尝试过的组合:
(基本上我玩过以下 Nuget 属性OutputDirectory
:BasePath
和Properties
)
顺便说一句,$(OutDir)
MSBuild 属性指向构建服务器上的正确文件夹
<Exec ContinueOnError="false" WorkingDirectory="$(OutDir)" Command=""$(SolutionDir).nuget\nuget.exe" pack "$(ProjectPath)" -Exclude "*.nlp" -IncludeReferencedProjects -NonInteractive -Verbosity detailed -NoDefaultExcludes -Properties Configuration="$(Configuration)";Platform="$(Platform)"" />
<Exec ContinueOnError="false" WorkingDirectory="$(ProjectDir)" Command=""$(SolutionDir).nuget\nuget.exe" pack "$(ProjectPath)" -Exclude "*.nlp" -IncludeReferencedProjects -NonInteractive -Verbosity detailed -NoDefaultExcludes -BasePath "$(OutDir)" -OutputDirectory "$(OutDir)"" />
<Exec ContinueOnError="false" WorkingDirectory="$(ProjectDir)" Command=""$(SolutionDir).nuget\nuget.exe" pack "$(ProjectPath)" -Exclude "*.nlp" -IncludeReferencedProjects -NonInteractive -Verbosity detailed -NoDefaultExcludes -OutputDirectory "$(OutDir)"" />
<Exec ContinueOnError="false" WorkingDirectory="$(ProjectDir)" Command=""$(SolutionDir).nuget\nuget.exe" pack "$(ProjectPath)" -Exclude "*.nlp" -IncludeReferencedProjects -NonInteractive -Verbosity detailed -NoDefaultExcludes -BasePath "$(OutDir)" -OutputDirectory "$(OutDir)"" />
<Exec ContinueOnError="false" WorkingDirectory="$(ProjectDir)" Command=""$(SolutionDir).nuget\nuget.exe" pack "$(ProjectPath)" -Exclude "*.nlp" -IncludeReferencedProjects -NonInteractive -Verbosity detailed -NoDefaultExcludes -BasePath "$(OutDir)" -OutputDirectory "$(OutDir)" -Properties Configuration="$(Configuration)";Platform="$(Platform)"" />
<Exec ContinueOnError="false" WorkingDirectory="$(OutDir)" Command=""$(SolutionDir).nuget\nuget.exe" pack "$(ProjectPath)" -Exclude "*.nlp" -IncludeReferencedProjects -NonInteractive -Verbosity detailed -NoDefaultExcludes" />
我一直收到同样的错误:
NuGet.CommandLineException: Unable to find 'D:\Builds\23\somecompany\somebuildserver\Sources\NugetLibrary\bin\Release\NugetLibrary.dll'. Make sure the project has been built.
那么 Nuget 是否只是忽略了该BasePath
属性?为什么?我错过了什么?