VSTS: How to handle FileSystem WebPublishMethod in Visual Studio build step with multiple projects
You'll need to add extra build logic in your project do do that in only one invocation.
You can create a Directory.Build.props
file in your solution's root directory (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>
This allows you to set /p:PublishBaseUrl="$(build.artifactstagingdirectory)\\"
as parameter instead of PublishUrl
and the project name will be appended to the path.
Related videos on Youtube
Momo
I work as a software development manager, working mostly with C#, Azure and SQL Server.
Updated on September 14, 2022Comments
-
Momo over 1 year
I have a solution that contains two basic (not MVC or .Net Core) ASP.Net web applications, and a few libraries on which they depend.
I have a build definition in VSTS that contains a Visual Studio Build step, which builds the solution with MSBuild.
The default set of MSBuild arguments package each web application into a single file, to be deployed via 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 require the website to be published to the file system so that existing scripts can do the deployment.
Therefore I changed these arguments to:
/p:DeployOnBuild=true /p:DeployDefaultTarget=WebPublish /p:WebPublishMethod=FileSystem /p:publishUrl=$(build.artifactstagingdirectory)\website
This does indeed publish the two websites to the file system, but the problem is that it puts them both on top of each other in the same folder.
Is there a way of passing some sort of paramaterised URL to
publishUrl
such that the two websites can end up in different folders? Or must I make an MSBuild step for each project individually? -
Momo over 6 yearsOh absolutely splendid, thank you. Worked perfectly. I didn't think of using project property files.
-
Kevin Dimey about 5 yearsIn case your solution is not the root of your project files,
Directory.Build.props
needs to be placed in the root folder of your projects files, not the solution folder.