-
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
Populate new csproj format properties from Azure DevOps build pipeline task #1611
Comments
This is the powershell script I am using between running the GitVersion build task and the
|
You could also create/update the That would be a good addition to the Build Task, for example create You can have a look how we use it in GitVersion |
I haven't used props files before so I've been reading up on this file and I think I get how this might work. For example, this file could be created/updated to have something like the following (I'm totally guessing here).
In order to use Directory.Build.props for this purpose I can think of the following scenarios that would need to be handled:
If you can safely figure out how to handle existing Directory.Build.props files then this may work on Azure DevOps because creating/updating a Directory.Build.props file on the build agent repo wouldn't matter as the change would be cleared out after the build. This wouldn't work for the nuget package on a project because a create or update to a Have I totally missed the mark here? |
That's a good description of the the possible scenarios. As far as I understand, the AssemblyInfo can still be used for setting the version number for the sdk style projects. You can also pass them as build parameters similar to |
Yep, you could push those three properties into the build task. That does require a manual configuration of the build step though. The thing I like about the AssemblyInfo option on the existing build task (at least for full framework msbuild builds) is that it is a zero config effort on the build workflow. |
I've been thinking about this a bit more. The PowerShell script above is really just doing a similar action to what the AssemblyInfo logic does in the existing build task. It would be easier in the case of the new proj format though because it is xml rather than parsing the AssemblyInfo text file. This process still wouldn't work for the GitVersionTask NuGet package because it would change what is under source control. FYI, I've updated my script to include the other properties.
This works fine as a custom DevOps build task but it would be nice if GitVersion did this OOTB :) |
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. |
I still think this should be addressed |
Having |
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. |
Presumably GitVersionCore could include a custom implementation to support this. Similar to how the AssemblyInfo logic works - https://github.com/GitTools/GitVersion/blob/master/src/GitVersionCore/Extensions/VersionAssemblyInfoResources/AssemblyInfoFileUpdater.cs |
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. |
A pull request implementing this with tests will be accepted. |
We started using GitVersion recently in our AzureDevOps setup. All of our project are either in .Net Core and .Net Standard and none of them have the AssemblyInfo.cs file. We are currently using the PowerShell script provided here as a workaround, but that would be great if GitVersion task on Azure DevOps can update the csproj file and add the version. Thank you. |
Looking at taking care of this @asbjornu @arturcic as this is something I personally want for my AzDo pipelines. Given that users want a minimalistic configuration, I can see a couple of approaches
Alternatively, we could add a new switch I'm comfortable with either approach. I'm going to use https://www.fuget.org/packages/Microsoft.Build/16.5.0 (I think this is the go-to package for reading/writing project metadata) to handle the project files. |
@svengeance, I'm happy you're volunteering to look into this! Just a heads up of where we're heading with v6: We are hoping to introduce a new command-based CLI and also break GitVersion up in more independent parts, where dealing with specific build servers, output formats, serializations, etc., are compartementalized and made independent of each other. An introduction of an MSBuild dependency and more logic around it might therefore be wise to introduce after the groundworks for the new architecture is laid out. What do you think? |
I see, that sounds like a good move. I can see 3 ways forward
Personally I'd like to get a crack on this, so 1 or 2 are preferable to me, but I understand this is your timeline so let me know how you'd like to move forward |
I can right off the bat say that 1 is nowhere close to true, so if you don't mind doing 2, then let's have a look at it in a PR. Just beware that it may be postponed and in need of a rewrite it if becomes too big and unwieldy. |
Fair enough. I will try to implement it in such a way that it doesn't become a pain in the ass to move around. Hopefully I have something soon for you! |
@roryprimrose if you apply the GitVersion NuGet package on your project to ensure that the assembly information gets updated, wouldn't this avoid the need to use your PowerShell script? I've used the GitVersion NuGet package on my .NET Core project in order to get the correct assembly version and on Azure DevOps I have used the extension onlyo to ensure that the build number gets updated. |
The existing build tasks for Azure DevOps have long had the option to update AssemblyInfo.cs before running a build task (which is really sweet BTW). Is there going to be support in the future for updating the version/package metadata properties in the new csproj format from the build task?
I've previously used a powershell script to take the output of the GitVersion variables to manually go into all the csproj files and update the properties before running
dotnet build
. It would be great if a future version of the build task could do this OOTB.I'll try to find the powershell script I use which may better explain what I'm trying to achieve.
The text was updated successfully, but these errors were encountered: