我知道之前已经问过这个问题,但我找到的答案因某些原因对我不起作用。
请让我描述我的问题。
我正在使用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>
在与我的项目文件相同的级别,我有 nuspec 文件代表我的Nuget元数据,它看起来像:
<?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
)
BTW $(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
属性?为什么?我错过了什么?
答案 0 :(得分:9)
看起来您可能会遇到http://nuget.codeplex.com/workitem/1486。根据对该问题的评论,看起来将-Properties OutDir=$(OutDir)
添加到您的pack命令可能会修复它。
答案 1 :(得分:1)
您可能想尝试一下我的个人项目http://nuproj.codeplex.com/。它允许通过MSBuild创建NuGet包。