MSBuild excludes assembly builds

Is it possible to tell MSBuild NOT to copy satellite assemblies for a specific assembly or for everyone?

I have a nuget package that contains assemblies of resources, but I do not want to include them in my output.

Thanks.

+6
source share
2 answers

You can have a separate folder for deployment of type \ Build_Archive, where the output is also copied - and add some lines to the assembly script to copy your assemblies, but not satellites to these folders - this way, Build_Archive always has only the files necessary for deployment.

i.e. my current copies of the script are copied to the folder labeled build # and to the current folder - so Current always has the last value, and we save the history of previous builds - for example:

C:\Build_Archive\AppName\Current C:\Build_Archive\AppName\1.0.0.1 C:\Build_Archive\AppName\1.0.0.2 

So, something like this at the end of your build script (replace <values> with your stuff. The script uses an external DLL to control version numbers, etc., so it doesn't turn on here):

  <!-- . . . --> <DropLocation>\\<serverName>\Build_Archive\${BuildDefinition}</DropLocation> <!-- . . . --> <!-- Version numbers major and build are replaced by outside calls not shown --> <PropertyGroup> <VersionMajor>1</VersionMajor> <VersionMinor>0</VersionMinor> <VersionService>0</VersionService> <VersionBuild>0</VersionBuild> </PropertyGroup> <Target Name="BuildNumberOverrideTarget"> <!-- Create a custom build number, matching the assembly version --> <!-- . . . --> <!-- … custom version code call – returns / sets VersionMajor and VersionBuild --> <PropertyGroup> <BuildNumber>$(BuildDefinitionName)_$(VersionMajor).$(VersionMinor).$(VersionService).$(VersionBuild)</BuildNumber> </PropertyGroup> <Message Text="Build number set to &quot;$(BuildNumber)&quot;" /> <Message Text="$(SolutionRoot)"/> </Target> <Target Name="AfterCompile"> <!-- Call Copy process after the build --> <CallTarget Targets="CleanUp"/> <CallTarget Targets="StageBuild"/> <CallTarget Targets="CopyFiles"/> </Target> <!-- Target : Clean Current Folder for next build --> <Target Name="CleanUp"> <Message Text="**** Entering::CleanUp ****"/> <CreateItem Include="\\<server name>\Build_Archive\<appName>\Current\**\*.*"> <Output ItemName="PreviousFiles" TaskParameter="Include" /> </CreateItem> <Delete Files="@(PreviousFiles)" ContinueOnError="true" /> </Target> <!-- Target:StageBuild --> <Target Name="StageBuild"> <ItemGroup> <BldCurrent Include="\\<server name>\Build_Archive\<appName>\Current\"/> </ItemGroup> <Message Text="@(BldCurrent)"/> <Message Text="$(SolutionRoot)"/> <!β€” Here – replace next line with commands to copy only the files you want to deploy --> <Exec Command="xcopy /y /r /e $(SolutionRoot)\..\bin\*.* @(BldCurrent)"/> </Target> <!-- Target : Copy files from Current to BuildNum folder --> <Target Name="CopyFiles"> <Exec Command="xcopy /y /r /e $(DropLocation)\Current\Debug\*.* $(DropLocation)\$(BuildNumber)\Debug\"/> <Exec Command="Del /Q $(DropLocation)\Current\Debug\*.config"/> <Exec Command="Del /Q $(DropLocation)\Current\Debug\*.dll"/> <Exec Command="Del /Q $(DropLocation)\Current\Debug\*.exe"/> <Exec Command="Del /Q $(DropLocation)\Current\Debug\*.application"/> <Exec Command="Del /Q $(DropLocation)\Current\Debug\*.pdb"/> <Exec Command="Del /Q $(DropLocation)\Current\Debug\*.txt"/> <Exec Command="Del /Q $(DropLocation)\Current\Debug\*.xml"/> </Target> 
0
source

Try calling MSBuild with the following parameters:

 /p:UseWPP_CopyWebApplication=True /p:PipelineDependsOnBuild=False 

This will apply the web.config conversion, as VisualStudio does. In addition, the output of the bin folder is also the same as in the VisualStudio publication. Satellite assemblies are not directly copied to the bin folder and remain in the bin subfolders.

See also:

0
source

All Articles