Pretty much as the title suggests.
trigger: - master pr: - master pool: vmImage: 'windows-latest' variables: solution: '**/*.sln' buildPlatform: 'Any CPU' buildConfiguration: 'Release' steps: - task: [email protected] - task: [email protected] inputs: restoreSolution: '$(solution)' # Run SonarCloud Prep - task: [email protected] inputs: SonarCloud: 'SonarCloud' organization: 'myorg' scannerMode: 'MSBuild' projectKey: 'myapp' projectName: 'myappname' - task: [email protected] inputs: solution: '$(solution)' msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"' platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' - task: [email protected] inputs: platform: '$(buildPlatform)' configuration: '$(buildConfiguration)' # Run SonarCloud Analyser - task: [email protected] # Run SonarCloud Publish - task: [email protected] inputs: pollingTimeoutSec: '300'
The rename command I am referring too above is actually just the git move command for clarity.
I have since checked that the repo is up to date both locally and in the remote. I can see that the file has the new name in the repo. Azure still does not seem to pull or recognise this change despite picking up the commit and starting the pipeline job.
In response to this I created a dummy file with the old name, committed this and the Azure pipeline succeeded. I then decided to run a delete command from git to remove the dummy file, this then triggered the pipeline once again which has also failed as before.
This would suggest that Azure is not updating itself when running VSBuild. Surely this is not a bug as I would imagine the inability to rename or even delete files in a repo would be a pretty massive problem across Azure.
The error is below:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VisualStudio\v17.0\Web\Microsoft.Web.Publishing.targets(2672,5): Error : Copying file Scripts\diarysearch-2.0.11.js to obj\Release\Package\PackageTmp\Scripts\diarysearch-2.0.11.js failed. Could not find file ‘Scripts\diarysearch-2.0.11.js’.
OK so it turns out that this is technically a Visual Studio issue. The git rename (move command) has worked as expected and VS will build and successfully run the solution. However, since the project file is not updated with the new name, this is why the Azure pipeline fails.
I am not sure how the project in VS can successfully build without updating the project file but this seems to be where the problem stems from.
So the solution is to basically remove and re-add the file from the VS project and re-commit.
Answered By – David Hirst