Djordje
Djordje

Reputation: 457

How to use publish profile options from Visual Studio in azure pipelines?

I have an ASP.NET project and I want to implement CI-CD using Azure pipelines, to deploy to custom server (IIS). Currently, when using Visual Studio(2019) to publish web application manually, I am using these options for publish profile:

  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <PublishProvider>FileSystem</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>True</ExcludeApp_Data>
    <publishUrl>C:\Test</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
    <PrecompileBeforePublish>True</PrecompileBeforePublish>
    <EnableUpdateable>False</EnableUpdateable>
    <DebugSymbols>False</DebugSymbols>
    <WDPMergeOption>MergeEachIndividualFolder</WDPMergeOption>
    <UseMerge>True</UseMerge>
  </PropertyGroup>

The main thing that I want to achieve, is implementing <WDPMergeOption>MergeEachIndividualFolder</WDPMergeOption> when deploying using build and release pipeline.

Things I've tried:

1. Passing configuration arguments to msbuild, for Build Solution task in azure build pipeline:

/p:PackageAsSingleFile=true /p:PackageLocation="$(build.artifactstagingdirectory) /p:OutputPath=bin 

/p:DeployOnBuild=true /p:WebPublishMethod=FileSystem  /p:PrecompileBeforePublish=true 

/p:EnableUpdateable=false /p:DebugSymbols=true  /p:UseMerge=true /p:DeleteAppCodeCompiledFiles=True 

/p:DeleteExistingFiles=True  /p:WDPMergeOption=MergeEachIndividualFolder /p:UseFixedNames=true\\"

2. Uploading FolderProfile.pubxml , and passing arguments to msbuild to read from that file

It all builds and releases fine, but doesn't merge assemblies in release, as configured with merge options, it seems like msbuild ignores these additional merge arguments.

How can this be done, the main question is how can I use MergeEachIndividualFolder option when deploying with azure pipeline?

I've also searched a lot, but non of the questions seems to cover the solution.

Azure DevOps Build - publish doesn't create .compiled files in bin folder on publish

MSBuild commandline seems to ignore publish properties

Upvotes: 5

Views: 11920

Answers (1)

Jeff Fol
Jeff Fol

Reputation: 1410

The recommendation from Cece Dong - MSFT worked in my instance of using a publish profile.

Snippet below YML

- task: VSBuild@1
  inputs:
    solution: 'Path\MySolution.sln'
    vsVersion: '16.0'
    msbuildArgs: '/p:DeployOnBuild=true /p:PublishProfile=myProfile.pubxml'
    configuration: 'Release'

Then in the output the build you can see it having the desired effect:

WebFileSystemPublish: Creating directory "C:\MyPublishPath". Copying obj\Release\Package\PackageTmp\File1.ext to C:\MyPublishPath\File1.ext. Copying obj\Release\Package\PackageTmp\File2.ext to C:\MyPublishPath\File2.ext. Copying obj\Release\Package\PackageTmp\bin\File3.ext to C:\MyPublishPath\bin\File3.ext. Copying obj\Release\Package\PackageTmp\bin\File4.ext to C:\MyPublishPath\bin\File4.ext. ... all other files included in the publish

Upvotes: 2

Related Questions