KeithS
KeithS

Reputation: 71565

How to force build-friendly root path convention in web site solution file

We're using VS 2019, working with a legacy "Web Site" project. The solution file created by using "File->Open->Web Site..." and then saved to the root of the folder structure thus opened, references the physical paths and solution relative path of the pseudoproject as "..\MyProject\", thus VS, MSBuild and other tools are told to expect the solution and its content to always live in a folder named "MyProject". That's perfectly fine when working with local Dev copies, the whole team just checks the source out to a folder path ending in "MyProject" and VS is perfectly happy.

The problem arises when trying to build and deploy the site with Azure DevOps pipes. The build agents do not check out the repository code to any such directory; the default local repo root for the "windows-latest" agent config is D:/a/1/s/, thus the build very correctly fails to find the path D:/a/1/MyProject/ that doesn't exist. Build agents, far as we can tell, do not allow us to customize these paths.

I can manually edit the solution file to change these paths from "..\MyProject\" to the simpler and more universally-correct ".\", and that works when run by the build agent. However, VS refuses to keep this convention; any change to the solution causes VS to revert these paths to ..\MyProject\.

Are there any suggestions besides "convert it to a more modern architecture" (we'd love to, really, it's not an option for "non-technical reasons" and let's leave it at that)?

Upvotes: 0

Views: 449

Answers (1)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35109

In Azure DevOps YAML Pipeline, we can change the checkout path via using the checkout statement.

By default, repo files will be checked out to the source folder(D:/a/1/s/). But we can change it by setting path value.

For example:

steps:

- checkout: self
  path: MyProject

The Repo will be checkout to path: $(Pipeline.Workspace)\MyProject ($(Pipeline.Workspace) = D:/a/1)

So the checkout path: D:/a/1/MyProject/

Result:

enter image description here

For more detailed info, you can refer to YAML schema.

path: string # Where to put the repository. The root directory is $(Pipeline.Workspace).

Upvotes: 1

Related Questions