Skip to content

Add local project file location to exception when parsing fails #3179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

chhh
Copy link

@chhh chhh commented Aug 26, 2022

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:

  • 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.
  • All new and existing tests passed.

@asbjornu
Copy link
Member

asbjornu commented Aug 27, 2022

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 57e2192 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 asbjornu changed the base branch from main to support/5.x August 27, 2022 21:30
@chhh chhh force-pushed the feature/report-project-file-location branch from 57e2192 to f68d347 Compare August 29, 2022 20:09
@chhh
Copy link
Author

chhh commented Aug 29, 2022

@asbjornu Done

@asbjornu
Copy link
Member

asbjornu commented Sep 2, 2022

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?

Helps in solutions with multiple projects, when one of csproj files
becomes corrupt. User knows where to apply fixes.
@arturcic arturcic force-pushed the feature/report-project-file-location branch from f68d347 to cac4eb1 Compare October 25, 2022 10:44
@arturcic arturcic merged commit 819f116 into GitTools:support/5.x Oct 25, 2022
@mergify
Copy link
Contributor

mergify bot commented Oct 25, 2022

Thank you @chhh for your contribution!

RatserX added a commit to RatserX/GitVersion that referenced this pull request Nov 3, 2022
commit f76d8b8
Merge: f6d86dc 8c6175c
Author: Artur <[email protected]>
Date:   Wed Oct 26 09:05:35 2022 +0200

    Merge pull request GitTools#3246 from arturcic/feature/markdown-lint

    Fix docs markdown lint errors

commit 8c6175c
Author: Artur <[email protected]>
Date:   Wed Oct 26 08:40:13 2022 +0200

    GitTools#2964 - disable tests for .net48

commit 21c34fb
Author: Artur <[email protected]>
Date:   Wed Oct 26 02:07:16 2022 +0200

    GitTools#2964 - use bash for reporter

commit 93f4637
Author: Artur <[email protected]>
Date:   Tue Oct 25 23:50:45 2022 +0200

    GitTools#2964 fix markdown linting errors

commit 18586fe
Author: Artur <[email protected]>
Date:   Tue Oct 25 19:21:56 2022 +0200

    GitTools#2964 fix html-proofer errors

commit f6d86dc
Author: Artur <[email protected]>
Date:   Tue Oct 25 16:15:45 2022 +0200

    (build) fix set-output syntax

    https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

commit 2cc427c
Author: Artur <[email protected]>
Date:   Tue Oct 25 15:25:27 2022 +0200

    Revert "(build) fix set-output syntax"

    This reverts commit b906175.

commit b812802
Author: Artur <[email protected]>
Date:   Tue Oct 25 15:49:10 2022 +0200

    Revert "(build) fix set-output syntax"

    This reverts commit b07a8b9.

commit b07a8b9
Author: Artur <[email protected]>
Date:   Tue Oct 25 15:49:10 2022 +0200

    (build) fix set-output syntax

    https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

commit b906175
Author: Artur <[email protected]>
Date:   Tue Oct 25 15:25:27 2022 +0200

    (build) fix set-output syntax

    https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

commit 34f9de7
Author: Artur <[email protected]>
Date:   Tue Oct 25 14:08:54 2022 +0200

    (build) update the actions/[email protected]

commit f954025
Author: Artur <[email protected]>
Date:   Tue Oct 25 14:01:52 2022 +0200

    (build) update the actions/[email protected]

commit 819f116
Merge: 8cd3a1b cac4eb1
Author: Artur <[email protected]>
Date:   Tue Oct 25 13:26:41 2022 +0200

    Merge pull request GitTools#3179 from chhh/feature/report-project-file-location

    Add local project file location to exception when parsing fails

commit cac4eb1
Author: Dmitry Avtonomov <[email protected]>
Date:   Fri Aug 26 13:38:47 2022 -0700

    Add local project file location to exception when parsing fails

    Helps in solutions with multiple projects, when one of csproj files
    becomes corrupt. User knows where to apply fixes.

commit 8cd3a1b
Merge: 3e5d1e7 1071e1c
Author: Asbjørn Ulsberg <[email protected]>
Date:   Tue Oct 25 11:26:26 2022 +0200

    Merge pull request GitTools#3208 from AlexPykavy/main

    Don't consider "tag-prefix" as optional if it's explicitly specified

commit 1071e1c
Author: Alexander Pykavy <[email protected]>
Date:   Mon Sep 26 21:12:26 2022 +0200

    Don't consider "tag-prefix" as optional if it's explicitly specified

    To correctly calculate the next version with the prefix.

    For example, we develop the main product and some its plugin
    in the same repository and have the following git tags list:
    - 0.1.0
    - 0.1.1
    - 0.2.0
    - 0.2.1
    - plugin_0.1.0
    - plugin_0.1.1

    The expected next plugin version is `0.1.2` not `0.2.2` (`plugin_` prefix
    will be prepended before setting the tag).
RatserX added a commit to RatserX/GitVersion that referenced this pull request Nov 3, 2022
commit f76d8b8
Merge: f6d86dc 8c6175c
Author: Artur <[email protected]>
Date:   Wed Oct 26 09:05:35 2022 +0200

    Merge pull request GitTools#3246 from arturcic/feature/markdown-lint

    Fix docs markdown lint errors

commit 8c6175c
Author: Artur <[email protected]>
Date:   Wed Oct 26 08:40:13 2022 +0200

    GitTools#2964 - disable tests for .net48

commit 21c34fb
Author: Artur <[email protected]>
Date:   Wed Oct 26 02:07:16 2022 +0200

    GitTools#2964 - use bash for reporter

commit 93f4637
Author: Artur <[email protected]>
Date:   Tue Oct 25 23:50:45 2022 +0200

    GitTools#2964 fix markdown linting errors

commit 18586fe
Author: Artur <[email protected]>
Date:   Tue Oct 25 19:21:56 2022 +0200

    GitTools#2964 fix html-proofer errors

commit f6d86dc
Author: Artur <[email protected]>
Date:   Tue Oct 25 16:15:45 2022 +0200

    (build) fix set-output syntax

    https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

commit 2cc427c
Author: Artur <[email protected]>
Date:   Tue Oct 25 15:25:27 2022 +0200

    Revert "(build) fix set-output syntax"

    This reverts commit b906175.

commit b812802
Author: Artur <[email protected]>
Date:   Tue Oct 25 15:49:10 2022 +0200

    Revert "(build) fix set-output syntax"

    This reverts commit b07a8b9.

commit b07a8b9
Author: Artur <[email protected]>
Date:   Tue Oct 25 15:49:10 2022 +0200

    (build) fix set-output syntax

    https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

commit b906175
Author: Artur <[email protected]>
Date:   Tue Oct 25 15:25:27 2022 +0200

    (build) fix set-output syntax

    https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/

commit 34f9de7
Author: Artur <[email protected]>
Date:   Tue Oct 25 14:08:54 2022 +0200

    (build) update the actions/[email protected]

commit f954025
Author: Artur <[email protected]>
Date:   Tue Oct 25 14:01:52 2022 +0200

    (build) update the actions/[email protected]

commit 819f116
Merge: 8cd3a1b cac4eb1
Author: Artur <[email protected]>
Date:   Tue Oct 25 13:26:41 2022 +0200

    Merge pull request GitTools#3179 from chhh/feature/report-project-file-location

    Add local project file location to exception when parsing fails

commit cac4eb1
Author: Dmitry Avtonomov <[email protected]>
Date:   Fri Aug 26 13:38:47 2022 -0700

    Add local project file location to exception when parsing fails

    Helps in solutions with multiple projects, when one of csproj files
    becomes corrupt. User knows where to apply fixes.

commit 8cd3a1b
Merge: 3e5d1e7 1071e1c
Author: Asbjørn Ulsberg <[email protected]>
Date:   Tue Oct 25 11:26:26 2022 +0200

    Merge pull request GitTools#3208 from AlexPykavy/main

    Don't consider "tag-prefix" as optional if it's explicitly specified

commit 1071e1c
Author: Alexander Pykavy <[email protected]>
Date:   Mon Sep 26 21:12:26 2022 +0200

    Don't consider "tag-prefix" as optional if it's explicitly specified

    To correctly calculate the next version with the prefix.

    For example, we develop the main product and some its plugin
    in the same repository and have the following git tags list:
    - 0.1.0
    - 0.1.1
    - 0.2.0
    - 0.2.1
    - plugin_0.1.0
    - plugin_0.1.1

    The expected next plugin version is `0.1.2` not `0.2.2` (`plugin_` prefix
    will be prepended before setting the tag).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Improvement] Report xml file location when xml parsing fails
3 participants