能否告诉MSBuild不要为某个程序集或所有程序集复制卫星程序集?
我有一个NuGet包,其中包含资源程序集,但我不想将它们包含在我的输出中。
谢谢。
能否告诉MSBuild不要为某个程序集或所有程序集复制卫星程序集?
我有一个NuGet包,其中包含资源程序集,但我不想将它们包含在我的输出中。
谢谢。
C:\Build_Archive\AppName\Current
C:\Build_Archive\AppName\1.0.0.1
C:\Build_Archive\AppName\1.0.0.2
在您的构建脚本末尾添加类似以下内容(将<values>
替换为您自己的内容。我们的脚本使用外部DLL来管理版本号等,因此此处不包括):
<!-- . . . -->
<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>
/p:UseWPP_CopyWebApplication=True /p:PipelineDependsOnBuild=False
这将应用与VisualStudio相同的web.config转换。此外,bin文件夹输出与VisualStudio发布相同。卫星程序集未直接复制到bin文件夹中,而是保留在它们的bin子文件夹中。
另请参见: