0

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?

marc_s
759k185 gold badges1.4k silver badges1.5k bronze badges
asked Oct 1 at 18:22
1
  • Not clear what benefits are by having multiple web site projects in one project. You still in theory required to deploy/publish each project as separate anyway, so I don't know what you gain here. If you looking to share code, then move that code out to a separate class of which then any and all of the 3 projects can reference that "code only" class project - and that will work correctly. Regardless, you would have to configure each subfolder as a whole new "separate" site anyway - once again, I see little benefits here. Sharing some common code in a new project class is easy, and works well. Commented Oct 2 at 4:01

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.