I am using NuGet pack for the first time, using the AfterBuild target in the .csproj file.
<Target Name="AfterBuild">
<!-- package with NuGet -->
<Exec WorkingDirectory="$(BaseDir)" Command="$(NuGetExePath) pack -Verbose -OutputDirectory $(OutDir) -Symbols -Prop Configuration=$(Configuration)" />
</Target>
This works fine when building the project itself with msbuild ("msbuild MyProj.csproj"). NuGet is able to find the compiled assemblies in projectdir/bin/Release or projectdir/bin/Debug.
But, this project is one of many in a solution and there is a build file dedicated to building the entire solution. The directory tree is like this:
- project root
- build
- src
- MyProj
- MyProj.csproj
- MyProj.nuspec
- AnotherProj
- AnotherProj.csproj
- AnotherProj.nuspec
- project.proj (msbuild file)
This msbuild file overrides the output path of the Visual Studio build.
<PropertyGroup>
<CodeFolder>$(MSBuildProjectDirectory)\src</CodeFolder>
<CodeOutputFolder>$(MSBuildProjectDirectory)\build\$(Configuration)</CodeOutputFolder>
</PropertyGroup>
<Target Name="Build" DependsOnTargets="CleanSolution">
<Message Text="============= Building Solution =============" />
<Message Text="$(OutputPath)" />
<Message Text="$(BuildTargets)" />
<MsBuild Projects="$(CodeFolder)\$(SolutionName)"
Targets="$(BuildTargets)"
Properties="Configuration=$(Configuration);RunCodeAnalysis=$(RunCodeAnalysis);OutDir=$(OutputPath);" />
</Target>
Now that the build redirects the assemblies to the build directory, when I run pack, NuGet can't find them. How do I get NuGet to find the assemblies in the build directory?