GitVersion icon indicating copy to clipboard operation
GitVersion copied to clipboard

Add local project file location to exception when parsing fails

Open chhh opened this issue 1 year ago • 3 comments

Description

Just wrap xml parsing call in try/catch. Helps in solutions with multiple projects, when one of csproj files becomes corrupt. User knows where to apply fixes.

Related Issue

Fixes #3178.

Motivation and Context

Updating csproj files in a large solution with multiple projects.

How Has This Been Tested?

  • Ran it in a well-formed solutio with well formed projects - ran fine as usual.
  • Corrupted one of csproj files by inserting a few random characters before the starting <Project element. This causes System.Xml.Linq.XElement.Parse() method call to fail parsing. The printed error log after applying the change contained the location of the file and all the same information as before as well (location within the file where the parsing error occured) as well as git log lines.

Screenshots (if appropriate):

Checklist:

  • [x] My code follows the code style of this project.
  • [ ] My change requires a change to the documentation.
  • [ ] I have updated the documentation accordingly.
  • [ ] I have added tests to cover my changes.
  • [x] All new and existing tests passed.

chhh avatar Aug 26 '22 22:08 chhh

This seems simple enough and something we should be able to roll into v5 as it isn't a breaking change. Do you mind changing your target branch to support/5.x so we can get this into production more quickly than if we have to wait for v6 (main represents v6) to be done?

I've changed the PR, but as you can see, all main commits are now a part of this PR, which is a bit unfortunate. All you need to do is reset your local branch to support/5.x, cherry-pick 57e2192c8addf5d7efe85dbd4d3f94c8264fa09a and then force-push:

git remote add upstream https://github.com/GitTools/GitVersion.git
git fetch upstream
git checkout feature/report-project-file-location
git reset --hard upstream/support/5.x
git cherry-pick 57e2192c8addf5d7efe85dbd4d3f94c8264fa09a
git push --force

asbjornu avatar Aug 27 '22 21:08 asbjornu

@asbjornu Done

chhh avatar Aug 29 '22 20:08 chhh

Meh, unfortunately a lot of tests are failing:

Error: unknown test file type for 'artifacts/test-results/GitVersion.MsBuild.Tests.net5.0.results.xml'

Have you seen this before, @arturcic?

asbjornu avatar Sep 02 '22 09:09 asbjornu

Thank you @chhh for your contribution!

mergify[bot] avatar Oct 25 '22 11:10 mergify[bot]