VSTS: how to handle FileSystem WebPublishMethod at the Visual Studio build stage with multiple projects

I have a solution that contains two main (not MVC or .Net Core) ASP.Net web applications and several libraries on which they depend.

I have a build definition in VSTS that contains a Visual Studio Build step that builds a solution using MSBuild.

The default set of MSBuild arguments packs each web application into a single file, which must be deployed through a batch file:

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactstagingdirectory)\\"

I cannot use this method and requires the site to be published to the file system so that existing scripts can perform the deployment.

So I changed these arguments to:

/p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:publishUrl=$(build.artifactstagingdirectory)\website

This is indeed the publication of two websites in the file system, but the problem is that it puts them on top of each other in the same folder.

Is there a way to pass some kind of parameterized URL to publishUrlso that these two websites can end up in different folders? Or should I do the MSBuild step for each project separately?

+4
source share
1 answer

You need to add additional build logic to your project in order to do this in only one call.

You can create a file Directory.Build.propsin the root directory of the solution (so that all web projects are below it in the directory hierarchy) with the following contents:

<Project>
  <PropertyGroup>
    <PublishUrl Condition="'$(PublishBaseUrl)' != '' and '$(PublishUrl)' == ''">$(PublishBaseUrl)\$(MSBuildProjectName)\</PublishUrl>
  </PropertyGroup>
</Project>

/p:PublishBaseUrl="$(build.artifactstagingdirectory)\\" PublishUrl, .

+3

Source: https://habr.com/ru/post/1684458/


All Articles