NuGet pack and msbuild - how can I build link assemblies elsewhere?

I am using the NuGet package 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 great when creating the project itself with msbuild ("msbuild MyProj.csproj"). NuGet can find compiled assemblies in the projectdir / bin / Release or projectdir / bin / Debug file.

But this project is one of many in the solution, and there is an assembly file dedicated to creating the whole solution. The directory tree looks 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 assembly redirects the assemblies to the assembly directory, when I run the package, NuGet cannot find them. How to get NuGet to search for assemblies in the assembly directory?

+7
source share
2 answers

Providing the NuGet TargetPath property for where to find the assembly 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> 
+15
source

Try to define the file section in your * .nuspec files, set the copy Copy to Output Directory property Copy to Output Directory Copy always or Copy if newer for them in the VS properties. After that, all of you compiled files and nuspecs will be in $(OutputPath) . And then change AfterBuild to:

 <Target Name="AfterBuild"> <PropertyGroup> <NuspecPath>$([System.IO.Path]::Combine($(OutputPath), "$(ProjectName).nuspec"))</NuspecPath> </PropertyGroup> <!-- package with NuGet --> <Exec WorkingDirectory="$(BaseDir)" Command="$(NuGetExePath) pack $(NuspecPath) -Verbose -OutputDirectory $(OutDir) -Symbols -Prop Configuration=$(Configuration)" /> </Target> 
+3
source

All Articles