-
Notifications
You must be signed in to change notification settings - Fork 653
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
Add GitVersion_CommandLineArguments parameter to MSBuild task #3022
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a welcome change, especially the added documentation, but the title of the PR seems to be wrong (should probably say Added GitVersion_CommandLineArguments parameter to MSBuild task
) and I would love to have a test added for this. You can see some tests exercising the MSBuild Task here:
GitVersion/src/GitVersion.MsBuild.Tests/Tasks/GetVersionTaskTests.cs
Lines 27 to 41 in 3297736
[Test] | |
public void GetVersionTaskShouldReturnVersionOutputVariables() | |
{ | |
var task = new GetVersion(); | |
using var result = ExecuteMsBuildTask(task); | |
result.Success.ShouldBe(true); | |
result.Errors.ShouldBe(0); | |
result.Task.Major.ShouldBe("1"); | |
result.Task.Minor.ShouldBe("2"); | |
result.Task.Patch.ShouldBe("4"); | |
result.Task.MajorMinorPatch.ShouldBe("1.2.4"); | |
result.Task.FullSemVer.ShouldBe("1.2.4+1"); | |
} |
@asbjornu yes, you are correct about the pull request name. I had two branches, and was considering making pull request for Config override too. As for MSBuild script tests. Looked into code once again, and still don't see easy way to do it. Test you pointed out tests MSBuild Task directly without even touching MSBuild scripts. Yet my changes are in .props file and even more, they are not affecting GetVersion task, they are affecting parameters of the Exec task. Well, I have some idea how to do this: there are other tests that create .csproj and run msbuild on it. I would probably build on that by injecting both .props and .targets into blank .csproj in order to mimic what nuget reference does. But then I would need to find compiled gitversion.dll, which would probably involve adding dependency on GitVersion.App to tests. And it would test way more than just adding one parameter that is then literally passed down to Exec. Nothing impossible, but 1) feels way out of scope of this pull request. 2) Changing architecture of solution is not something I like to do on my own initiative in my first pull request on project I'm just getting myself familiarized with :) |
I agree that the amount of heavy lifting you're describing is a bit much to ask for in a first contributor PR, @professor-k. I do have a feeling we have or at least had something along the lines you describe in place, though. Do you know, @arturcic? |
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs. Thank you for your contributions. |
Thank you @professor-k for your contribution! |
🎉 This issue has been resolved in version 5.11.0 🎉 Your GitReleaseManager bot 📦🚀 |
|
Implemented generic way to pass arbitrary command line parameter for GetVersion.
Description
This parameter allows to pass arbitrary string which is then literally passed down to Exec.
Related Issue
Fixes #3021.
Motivation and Context
Allows to pass in arbitrary extra parameters with just one parameter
How Has This Been Tested?
Couple manual runs with or without this parameter, both via dotnet/msbuild command line /p key, and via variable declaration in the csproj file. I looked into the code and it doesn't look like there is anything to test msbuild scripts per se. As for C# code I didn't touch it (to be fair, I wasn't even able to open solution, as VS 2022 was hanging every time I was trying to do so).
As for documentation, I got
Error: The target 'Preview-Documentation' was not found.
. Something must be broken. Anyway, I wrote couple lines section in documentation for MsBuild GetVersion configuration, and it looks okay when viewed via GitHub. Just make sure to proofread, as I'm not a native speaker.Screenshots (if appropriate):
Checklist: