Is it possible to tell MSBuild to NOT copy the satellite asssemblies for a certain assembly or for all?
I have a nuget package, which contains resource assemblies, but I do not want to include them in my output.
Thanks.
Is it possible to tell MSBuild to NOT copy the satellite asssemblies for a certain assembly or for all?
I have a nuget package, which contains resource assemblies, but I do not want to include them in my output.
Thanks.
You could have a separate folder for deployment like \Build_Archive where output is copied too - and add some lines to the build script to copy your assemblies, but not the satellite-assemblies to those folders - that way, the Build_Archive always has just the files needed for your deployment.
i.e. my current script copies to the build# labeled folder and to the Current folder - so Current always has the latest, and we maintain a history of prior builds - like:
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>
for your stuff. Our script uses an external DLL to manage version numbers, etc. so not included 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 "$(BuildNumber)"" />
<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>
Try to call the MSBuild with this parameters:
/p:UseWPP_CopyWebApplication=True /p:PipelineDependsOnBuild=False
This will apply web.config transformation as VisualStudio would do. In addition, the bin folder output is also the same as in a VisualStudio publish. Satellite Assemblies are not copied directly into the bin folder and remain in their bin subfolders.
See also:
© 2022 - 2024 — McMap. All rights reserved.