-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Git commit ID included in assembly ProductVersion field when building with sdk 8 #34568
Comments
I believe this is related to some pieces of source link being enabled by default. @tmat to point to any documentation or announcement about this. I believe if you set EnableSourceLink to false, it'll restore the old behavior. |
There's also the |
It is necessary to enable source link support when developing, but this behavior change will only appear when updating the SDK, and if it is intentional, it should be pointed out in the change log. But I don't think this behavior should be enabled by default. |
The implicit Source Link is listed in https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-8#source-link but that doesn't say it will affect ProductVersion. |
Related issue for ProductVersion of NuGet.Common.dll and similar assemblies: NuGet/Home#11974 |
@PurplestViper @KalleOlaviNiemitalo |
Simply upgrading the sdk will cause some programs that detect InformationalVersion to fail. Although setting
This issue has not received an effective reply three months since it was opened. I hope to observe the butterfly effect by changing the issue status. Now I found this issue dotnet/docs#37674 . |
@PurplestViper Source Link is intentionally enabled by default. The breaking change in version attribute is documented in https://learn.microsoft.com/en-us/dotnet/core/compatibility/sdk/8.0/source-link. |
Really poor decision to do this, and not even mention this. I just wasted 8 hours combing build plans trying to work out where tis was coming from.. I now have to edit 400 project files and add a new property to disable the daft behavior. |
You could do it in a single file, but I agree, making this the default behavior is a breaking change for many. |
Maybe you could use Directory.Build.props to define it globally |
https://developercommunity.visualstudio.com/t/Build-adds-string-to-assembly-Informatio/10515014 I logged an issue here noting this change affected my .NET 4.7.1 project, where the SDK documentation clearly indicates this should affect .NET 8+ only. My reading of the discussion thus far suggests this is not what this present issue is intended to address. Am I right, and I should raise another issue to address that particular issue? |
Any .NET SDK project (i.e. project that specifies To disable this new behavior you can include <Project>
<PropertyGroup>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
</Project> |
Thank you @tmat, that was my fix. That was not how I read the documentation, however, it says:
It reads like it's the target framework that should introduce the difference in behaviour. I can understand why the change in behaviour is not desired. Using .NET SDK 8 was not a conscious decision, it's something that happened for me merely by virtue of updating Visual Studio to 17.8. Surely such breaking changes should only occur when making a deliberate decision to update the target framework version? I'm sure I'm not alone in this: why look for documentation about breaking changes when I have not actually made any changes? |
Is there a way to disable this behaviour in .NET SDK? I see some suggested to use a single file to disable this but what if you have over 100 repositories? Do we need to add this single file to every single repository? There must be a better way of disabling this. |
I would use exactly that approach with the |
Or you could set |
@marcpopMSFT @tmat |
You can use
|
Upgrading .net sdk shouldn't force users to change their build scripts. This behaviour should have been default to false. Anyone interested could enable this. Bad decision. |
Hi, I agreed with many, this is a poor decision to have this new feature enabled by default as a) it changes the a public value (i.e. the file version in 'InformationalVersion') and b) it affects existing projects targeting previous version of .NET. Why not have intoduced another attribute(s) related to "commit information" if that was the intent, i.e. provide info about the commit. |
While you can debate on whether this change was necessary or not, the way it was implemented was definitely "not good" If such a breaking change is made it would have made sense that the IncludeSourceRevisionInInformationalVersion was explicitly set to true en the default project templates (even if that was the default) It should also not have been released without the IncludeSourceRevisionInInformationalVersion showing up in the intellisense when editing the project file. I know that the absolute first thing to do is to disable this in the project properties but I always have to copy it from another project / github as VS won't suggest it. |
@tmat @marcpopMSFT This issue should definitely not be closed. You guys have added a breaking change with the inclusion of Source Link and unfortunately the "fix" you have provided does not work correctly. I have included For example, we are compiling towards multiple target frameworks in our project file like so: When the project is built without the However, when we set that property to false and rebuild the projects, the property does not behave as you have indicated. As others have mentioned previously, this change should have been configured to support backwards compatibility first, especially for existing projects. It also seems to have not been carefully planned as the setting you are suggesting to use does not even work correctly for all target frameworks. Can you please re-open this issue and look into why the suggested property is not working in the scenario I have described? EDIT: The previous analysis was done with VS 2022 v17.9.3. I posted this as I was updating VS 2022 to v17.9.5. After the latest update, it does seem the behavior has changed but still seems something is not working correctly yet. With the property commented out, net8.0. net472 and netstandard2.0 include the git commit value as you intend, but net7.0 does not include it. This is inconsistent and I'm not sure what your default intention is (i.e. include git commit for all target frameworks in product version by default) or to just have it effect net8.0 exclusively. Regardless of the intention, this being inconsistent certainly suggests something is still not correct. The good news is that with the property explicitly set to false, under VS 2022 v17.9.5, all four target frameworks are correctly removing the git commit from the product version, so that is definitely a step in the right direction. I have not tested this with all possible target framework monikers that VS 2022 can compile, but it would see you guys should do some internal testing for all target framework monikers both as individual targets and in a collection as I have used, to verify the intended functionality is working correctly when you expect the git commit to be included as well as when it should not be included. I do see the benefit of this addition but again think it should not have been forced upon the development community as a breaking change. A much better approach would have been to include it in a new features summary page when loading Visual Studio after the update, highlighting the benefits of Source Link so we can see it's benefits and decide on our own if and when we want to implement it in our code. For a long time now Visual Studio updates have been pretty stable and changing to a new framework like NET 7 to NET 8 could be expected to have breaking changes. Just updating the IDE has typically not been one of those concerns. How this was done is a bit concerning for my team as this broke things that should not have been broken with a VS update. I really hope in the future the Microsoft team takes more care in making changes like this and does so with backwards compatibility being the first preference. I suspect if you continue to make changes like this in the future, that the community may start being weary of your regular Visual Studio updates, which I don't think anyone wants. I hope you keep these thoughts in mind going forward because based on this thread it's clear that most of us are not happy with how this was handled. |
@bryanfarrell Can you please share a repro project or a binlog showing that |
@tmat please see the edit to my original post. The setting when on seems to now be working, at least for the target frameworks we are using. As I've already updated Visual Studio and rebuilt the project, I have no binlog that I can share with you. As I mentioned in the edit, I would think a change like this should have a set of tests around it to make sure the behavior works correctly in all target framework configuration that VS 2022 supports. That at a minimum would make it easy for your team to verify that the expected behavior works as intended. |
@bryanfarrell I tried a simple library project with the following settings: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;net7.0;net8.0;netstandard2.0</TargetFrameworks>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>
</Project> As expected, git sha is not included in the versions of any of the output binaries. If it doesn't work for you your build must be doing something different. I can't tell what it is unless you provide a repro project or a binlog ( |
As I mentioned, with latest version of Visual Studio it is working when off but is not consistently working when the setting is ON. This is a private repo so I can't share that with you, and I am also not triggering this build directly with dotnet build, I am building from VS IDE. If you comment out |
Does it always work correctly when building form command line ( |
The intention is that it is set for all TFMs. I can't reproduce behavior that you're describing. The generated *AssemblyInfo.cs file in |
Perhaps it was caching the generated AssemblyInfo.cs file in the obj directory even though I cleaned and rebuilt the project. The good news is when I say to turn it off, it turns it off. So perhaps it's just a glitch with the obj folder not being cleared out. When I have time, I will see if I can clear everything completely and see if I get the same results. |
Ah, so this is what has been poisoning my telemetry data. Real smooth, really appreciate it Microsoft. |
Describe the bug
Starting from dotnet sdk 8 preview 4, building an assembly with dotnet will include the git commit id in the ProductVersion field by default, is there any chance it will be removed?
To Reproduce
Exceptions (if any)
Further technical details
dotnet --info
The text was updated successfully, but these errors were encountered: