I have an ASP.NET webforms project (A) which references two other webforms projects (B and C) that I'm trying to publish with precompilation enabled from the command line with MSBuild using a publish profile (.pubxml). I need to be able to script this for our build pipeline to create the appropriate artifact for a security scan.
I can publish project A from Visual Studio just fine; it precompiles and outputs in bin/app.publish as expected.
When I run the following MSBuild command it creates the app.publish directory with a _PublishedWebsites directory containing projects A, B, and C without precompilation.
msbuild .\path\to\projectA.csproj /p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile /p:OutputPath=$(pwd)\app.publish
MyPublishProfile.pubxml:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<DeleteExistingFiles>true</DeleteExistingFiles>
<ExcludeApp_Data>true</ExcludeApp_Data>
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\app.publish\</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<_TargetId>Folder</_TargetId>
<SiteUrlToLaunchAfterPublish />
<PrecompileBeforePublish>true</PrecompileBeforePublish>
<EnableUpdateable>false</EnableUpdateable>
<DebugSymbols>true</DebugSymbols>
<WDPMergeOption>CreateSeparateAssembly</WDPMergeOption>
<UseFixedNames>true</UseFixedNames>
</PropertyGroup>
</Project>
The only difference for projects B and C is that PrecompileBeforePublish is set to false in the .pubxml because I get assembly binding errors when it tries to precompile them.
Is there a way to direct MSBuild that I only want project A published, the way Visual Studio does?