I am building an Azure Pipeline running on a Windows Self Hosted agent. The project is an.Net 2.0 web site. I created a powershell script that connects to our on-prem TFS 2018 server and connect to the TFVC repository, it copies the files to the Agent\s folder.
When in VS2019, I used to Build the solution, right click the main folder and click Publish to copy only required files to the web site’s folder. I was ending with a clean folder, with no *.cs or extra configuration files.
I am trying to do the same thing with my pipeline. I currently have this task:
- task: VSBuild@1
inputs:
solution: '${{ parameters.solutionToPublishPath }}'
configuration: '${{ parameters.buildConfiguration }}'
restoreNugetPackages: false
createLogFile: true
logFileVerbosity: 'detailed'
This builds my solution but doesn’t publish it as I used to do in VS2019. I saw I could use this:
“msbuildArgs: '/p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:publishUrl="$(build.BinariesDirectory)\"'”
but this doesn’t seem to work, I’m really bad with MsBuild parameters.
After the build, I would want the result of the Publish action in the binaries folder and eventually zip the binaries in the artefact folder, like this:
Agent
--- \s
--- --- \depend1
--- --- \depend2
--- --- \portal
--- --- --- \bin\*
--- --- --- \module1\*.htm, *.aspx, *.ascx, *.cs
--- --- --- \module2\*.htm, *.aspx, *.ascx, *.cs
--- --- --- \*.htm, *.aspx, *.ascx, *.cs
--- \b
--- --- \portal
--- --- --- \bin\*
--- --- --- \module1\*.htm, *.aspx, *.ascx
--- --- --- \module2\*.htm, *.aspx, *.ascx
--- --- --- \*.htm, *.aspx, *.ascx
--- \a
--- --- \portal.zip
Do I need to call VSBuild@1 several times ? Can you help me setting up the MsBuild parameters ?
Thanks
If you want to use MSBuild Arguments to compress files to zip, you can use OutputPath, like this:
/p:OutputPath=c:\yourdir\output.zip
The following are my test and result:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:OutputPath=c:\testmsbuild\output.zip /p:PackageLocation="$(build.artifactstagingdirectory)\\"