この質問が以前にも出されたことは知っていますが、私が見つけた回答は何らかの理由でうまくいきませんでした。
私の問題を説明させてください。
Visual Studio 2012 と TFS 2012 を使用しています
私の組織では、いくつかのアプリケーションがあり、そのうちのいくつかは共有 DLL を公開しており、それらをプライベート Nuget サーバーで Nuget パッケージとして公開したいと考えています。
そのため、プロジェクトの 1 つで、次のコードを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
そのため、いくつかの組み合わせを試しましたが、ビルド プロセスによって生成された DLL を検索するために Nuget にカスタム パスを強制的に使用させる方法が見つかりません。
これまでに試した組み合わせは次のとおりです。
(基本的に、次の 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
プロパティを無視しているだけですか? なんで?私は何が欠けていますか?