Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8540559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:37:33+00:00 2026-06-11T11:37:33+00:00

I am using NuGet pack for the first time, using the AfterBuild target in

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:37:35+00:00Added an answer on June 11, 2026 at 11:37 am

    Giving NuGet a TargetPath property for where to find the assembly works for this.

    <Target Name="AfterBuild" Condition="'$(Configuration)' == 'Release' ">
      <!-- package with NuGet -->
      <Exec WorkingDirectory="$(BaseDir)" Command="$(NuGetExePath) pack -OutputDirectory $(OutDir) -Symbols -Prop Configuration=$(Configuration);TargetPath=$(OutDir)$(AssemblyName)$(TargetExt)" />
    </Target>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

To generate a NuGet package I'm currently using the command: nuget pack project.csproj -Prop
I am creating NuGet package and for that I have created Nuspec manifest file.
I have been using NuGet for quite some time on a particular PC. Now,
I'm trying to create my first NuGet package. I don't know why my install.ps1
I have been using Nuget package manager recently and have found it excellent. However
I have enabled NuGet Package Restore in my solution. I am using nuget.exe version
We are using NuGet server to serve our own package within the company. Since
Is there a way to get MarkdownSharp (I'm using the NuGet package ) to
I have basically loaded Elmah assemblies and installed the package using the NuGet plug-in.
I am using the awesom MVCDonutCaching package from Nuget in order to cache entire

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.