title: NuGet pack and msbuild - how can pack reference assemblies in another location?
body: <p>I am using NuGet pack for the first time, using the AfterBuild target in the .csproj file.</p>
  
  <pre><code>&lt;Target Name="AfterBuild"&gt;
    &lt;!-- package with NuGet --&gt;
    &lt;Exec WorkingDirectory="$(BaseDir)" Command="$(NuGetExePath) pack -Verbose -OutputDirectory $(OutDir) -Symbols -Prop Configuration=$(Configuration)" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>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.  </p>
  
  <p>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:</p>
  
  <pre><code>- project root
    - build
    - src
      - MyProj
        - MyProj.csproj
        - MyProj.nuspec
      - AnotherProj
        - AnotherProj.csproj
        - AnotherProj.nuspec
    - project.proj (msbuild file)
  </code></pre>
  
  <p>This msbuild file overrides the output path of the Visual Studio build.</p>
  
  <pre><code>&lt;PropertyGroup&gt;
    &lt;CodeFolder&gt;$(MSBuildProjectDirectory)\src&lt;/CodeFolder&gt;
    &lt;CodeOutputFolder&gt;$(MSBuildProjectDirectory)\build\$(Configuration)&lt;/CodeOutputFolder&gt;
  &lt;/PropertyGroup&gt;
  
  &lt;Target Name="Build" DependsOnTargets="CleanSolution"&gt;
    &lt;Message Text="============= Building Solution =============" /&gt;
    &lt;Message Text="$(OutputPath)" /&gt;
    &lt;Message Text="$(BuildTargets)" /&gt;
    &lt;MsBuild Projects="$(CodeFolder)\$(SolutionName)" 
             Targets="$(BuildTargets)"
                   Properties="Configuration=$(Configuration);RunCodeAnalysis=$(RunCodeAnalysis);OutDir=$(OutputPath);" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>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?</p>