-
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
[Hot Reload] ENC0003: Updating 'attribute' requires restarting the application
caused by AssemblyInformationalVersionAttribute
#36666
Comments
This might be related to Sourcelink being on by default in .Net 8 SDKs - it would impact the value in the AssemblyInformationalVersion if git commits were being made between hot reload refreshes. |
If this were a matter of new Git commits, then I'd expect the generated file to include some commit ID, rather than just |
Good call - I'm just a little sensitive to potentially SourceLink-related regressions, since we've seen a few of those in the latter part of this release. |
@KalleOlaviNiemitalo it may be so, the file you're seeing here may be one of the updated versions for that file (original or updated). That's the problem of generated files on disk by msbuild, they get re-generated by both VS and the hot reload workspace. |
Reading further about this |
Ok, so thanks to your insights, I now have a reliable repro:
|
@jeromelaban I followed the steps above but can't repro :(. The attribute is not changed, still contains the commit SHA. |
@jeromelaban Could you please capture and share the binary logs for design time build? When setting env variables before starting VS following the above instructions, could you also set
and share the content? |
@tmat Also experiencing this issue having update to the latest version of Visual Studio 17.8. .NET 7.0 WPF. I have attached my binary logs. The workaround suggested by @jeromelaban works but is pretty invasive to update all our projects in all our solutions. |
I am also intermittently experiencing this issue whilst debugging my Asp.Net Core 7 application in Visual Studio 17.8.0. Resuming after a breakpoint triggers a hot reload which fails with ENC0003 even though I have not made any code changes to warrant a reload. Logs attached, the change seems to involve something updating from (or to?):
to
in my AssemblyInfo file. Version info in my .csproj is
|
@SkinnySackboy Unrelated but FYI, the build logs show error:
|
I found the problem. A workaround is to set <Project>
<PropertyGroup>
<EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries>
</PropertyGroup>
</Project> @AlexKeene @SkinnySackboy Could you please try this workaround and confirm it works for you? Thanks! |
I had the same issue and this work around resolves the issue for me. |
@pvginkel Thanks for confirmation |
@tmat The WiX issue was unrelated but the EnableSourceControlManagerQueries setting seemed to do the trick, thanks! |
I have had this error since .NET 6. MS does nothing "unable to investigate further..." unless I debug it for them. Could you please go to the MS Developer Community in places like this: https://developercommunity.visualstudio.com/t/What-is-the-CS8984-error-Hot-Reload-doe/10508225#T-ND10543272 (and several other places) and voice your concern. Perhaps you have a repeatable situation they can decipher. |
I see the same issue. Started after installing VS 17.8. |
I find this issues with VisualStudio 2022 17.9.0 and dotnet 8.0.200 |
I'm hitting this too with VS 2022 Update 9. |
did this regress or was never properly fixed? |
ENC has appeared mostly broken for me for years. The last several months even F10 stepping fails sporadically without any edits at all, with the assembly attribute file(s) blamed as having changed when they haven't (though design-time builds maybe touched their timestamps). |
@AArnott Whenever you have issue with ENC having this env variable set for VS process to collect detailed logs and sharing the logs will help fixing it:
You can keep it set for a while and use VS as usual, then delete the directory once in a while. Feel free to ping me any time you have issue. |
Been seeing this a ton in VS 17.10.x. Makes hot reload almost impossible. I run the app, hit a breakpoint, step through a few, and when I click on continue to resume, it tells me that I deleted a bunch of fields (in files I haven't even opened) and then hot reload no longer works. Happens almost every single time for me. |
For everyone who's still seeing this, ensure that you use the latest version of the .NET SDK 8, as well as remove the package reference to Microsoft.SourceLink.*. SourceLink now comes in the SDK so you no longer need the PackageReference (e.g. Microsoft.SourceLink.AzureRepos.Git). Older versions of these packages have the incrementality bug which has been fixed in the SDK. |
@KirillOsenkov That's awesome. Does the SDK handle both GitHub and Azure Repos for source link purposes? |
Per @KirillOsenkov in [this comment](dotnet/sdk#36666 (comment)), SourceLink is now built into the .NET SDK.
I think so. I saw it work fine for Azure Repos. It's easy to check - if you have the Git SHA in the *.AssemblyInfo.cs in your obj, it means it works fine. |
Yes, GitHub, Azure Repos, GitLab, and BitBucket are included in the box |
I'm experiencing this issue too, because I'm using I'm running .NET 8 SDK 8.0.6 on Windows 10 x64 22H2.
...now because ...so I changed it to render a low-resolution timestamp when it's a
...but I find that even with this change (and the resultant ..and if I start Debugging from a non-DesignTimeBuild then that, too, will see the ...but this feels like a new behaviour to me: I've been using this MSBuild I'm asking if there's a way to have ENC work by ignoring any changes to ``\obj\net8.0\MyProject.AssemblyInfo.cs`. I also seem to be the only person on the Internet with this problem - so there's a hint I'm doing something wrong without realizing it. Are there any better approaches to adding a Build Date+Timestamp to an assembly that doesn't break ENC? |
What do you use the timestamp for? |
Currently, for two main reasons, and it's easy to think of a few more:
We do digitally-sign (AuthentiCode) most of our binaries, and we could get the signing-date (rather than the build date+time), but plenty of binaries and sometimes entire builds (especially builds made outside our CI+CD system and build-env) go without being code-signed (expediency is a legitimate reason), whereas build date+times can always be available in every build. |
...Reload'ing --- Visual Studio 2022, if you have a project that has Source Link and you attempt to make an edit to any of the kernel code as you debug it without rebuilding it, will go berserk with an error message that says to the effect of: <PROJECT>.AssemlyInfo.cs (line xx): error ENC0003: Updating 'attribute' requires restarting the application. as per issue dotnet/sdk#36666. If we've attempted to manually set <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> in the Directory.Build.props that define global properties of all the projects in a solution, the issue is fixed. This issue is not fixed yet when omitting this property. Investigating this further in the https://github.com/dotnet/sourcelink/blob/main/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props file, we've found something interesting. This property list file contains this line: <EnableSourceControlManagerQueries Condition="'$(EnableSourceControlManagerQueries)' == ''">true</EnableSourceControlManagerQueries> For some reason, this property is not being set, causing all sorts of 'attribute' update errors, despite being implicitly set to true in case this property doesn't exist. --- Type: fix Breaking: False Doc Required: False Backport Required: True Part: 1/1
...Reload'ing --- Visual Studio 2022, if you have a project that has Source Link and you attempt to make an edit to any of the kernel code as you debug it without rebuilding it, will go berserk with an error message that says to the effect of: <PROJECT>.AssemlyInfo.cs (line xx): error ENC0003: Updating 'attribute' requires restarting the application. as per issue dotnet/sdk#36666. If we've attempted to manually set <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> in the Directory.Build.props that define global properties of all the projects in a solution, the issue is fixed. This issue is not fixed yet when omitting this property. Investigating this further in the https://github.com/dotnet/sourcelink/blob/main/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props file, we've found something interesting. This property list file contains this line: <EnableSourceControlManagerQueries Condition="'$(EnableSourceControlManagerQueries)' == ''">true</EnableSourceControlManagerQueries> For some reason, this property is not being set, causing all sorts of 'attribute' update errors, despite being implicitly set to true in case this property doesn't exist. --- Type: fix Breaking: False Doc Required: False Backport Required: True Part: 1/1
...Reload'ing --- Visual Studio 2022, if you have a project that has Source Link and you attempt to make an edit to any of the kernel code as you debug it without rebuilding it, will go berserk with an error message that says to the effect of: <PROJECT>.AssemlyInfo.cs (line xx): error ENC0003: Updating 'attribute' requires restarting the application. as per issue dotnet/sdk#36666. If we've attempted to manually set <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> in the Directory.Build.props that define global properties of all the projects in a solution, the issue is fixed. This issue is not fixed yet when omitting this property. Investigating this further in the https://github.com/dotnet/sourcelink/blob/main/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props file, we've found something interesting. This property list file contains this line: <EnableSourceControlManagerQueries Condition="'$(EnableSourceControlManagerQueries)' == ''">true</EnableSourceControlManagerQueries> For some reason, this property is not being set, causing all sorts of 'attribute' update errors, despite being implicitly set to true in case this property doesn't exist. --- Type: fix Breaking: False Doc Required: False Backport Required: True Part: 1/1
...Reload'ing --- Visual Studio 2022, if you have a project that has Source Link and you attempt to make an edit to any of the kernel code as you debug it without rebuilding it, will go berserk with an error message that says to the effect of: <PROJECT>.AssemlyInfo.cs (line xx): error ENC0003: Updating 'attribute' requires restarting the application. as per issue dotnet/sdk#36666. If we've attempted to manually set <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> in the Directory.Build.props that define global properties of all the projects in a solution, the issue is fixed. This issue is not fixed yet when omitting this property. Investigating this further in the https://github.com/dotnet/sourcelink/blob/main/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props file, we've found something interesting. This property list file contains this line: <EnableSourceControlManagerQueries Condition="'$(EnableSourceControlManagerQueries)' == ''">true</EnableSourceControlManagerQueries> For some reason, this property is not being set, causing all sorts of 'attribute' update errors, despite being implicitly set to true in case this property doesn't exist. --- Type: fix Breaking: False Doc Required: False Backport Required: True Part: 1/1
...Reload'ing --- Visual Studio 2022, if you have a project that has Source Link and you attempt to make an edit to any of the kernel code as you debug it without rebuilding it, will go berserk with an error message that says to the effect of: <PROJECT>.AssemlyInfo.cs (line xx): error ENC0003: Updating 'attribute' requires restarting the application. as per issue dotnet/sdk#36666. If we've attempted to manually set <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> in the Directory.Build.props that define global properties of all the projects in a solution, the issue is fixed. This issue is not fixed yet when omitting this property. Investigating this further in the https://github.com/dotnet/sourcelink/blob/main/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props file, we've found something interesting. This property list file contains this line: <EnableSourceControlManagerQueries Condition="'$(EnableSourceControlManagerQueries)' == ''">true</EnableSourceControlManagerQueries> For some reason, this property is not being set, causing all sorts of 'attribute' update errors, despite being implicitly set to true in case this property doesn't exist. --- Type: fix Breaking: False Doc Required: False Backport Required: True Part: 1/1
...Reload'ing --- Visual Studio 2022, if you have a project that has Source Link and you attempt to make an edit to any of the kernel code as you debug it without rebuilding it, will go berserk with an error message that says to the effect of: <PROJECT>.AssemlyInfo.cs (line xx): error ENC0003: Updating 'attribute' requires restarting the application. as per issue dotnet/sdk#36666. If we've attempted to manually set <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> in the Directory.Build.props that define global properties of all the projects in a solution, the issue is fixed. This issue is not fixed yet when omitting this property. Investigating this further in the https://github.com/dotnet/sourcelink/blob/main/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props file, we've found something interesting. This property list file contains this line: <EnableSourceControlManagerQueries Condition="'$(EnableSourceControlManagerQueries)' == ''">true</EnableSourceControlManagerQueries> For some reason, this property is not being set, causing all sorts of 'attribute' update errors, despite being implicitly set to true in case this property doesn't exist. --- Type: fix Breaking: False Doc Required: False Backport Required: True Part: 1/1
...Reload'ing --- Visual Studio 2022, if you have a project that has Source Link and you attempt to make an edit to any of the kernel code as you debug it without rebuilding it, will go berserk with an error message that says to the effect of: <PROJECT>.AssemlyInfo.cs (line xx): error ENC0003: Updating 'attribute' requires restarting the application. as per issue dotnet/sdk#36666. If we've attempted to manually set <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> in the Directory.Build.props that define global properties of all the projects in a solution, the issue is fixed. This issue is not fixed yet when omitting this property. Investigating this further in the https://github.com/dotnet/sourcelink/blob/main/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props file, we've found something interesting. This property list file contains this line: <EnableSourceControlManagerQueries Condition="'$(EnableSourceControlManagerQueries)' == ''">true</EnableSourceControlManagerQueries> For some reason, this property is not being set, causing all sorts of 'attribute' update errors, despite being implicitly set to true in case this property doesn't exist. --- Type: fix Breaking: False Doc Required: False Backport Required: True Part: 1/1
...Reload'ing --- Visual Studio 2022, if you have a project that has Source Link and you attempt to make an edit to any of the kernel code as you debug it without rebuilding it, will go berserk with an error message that says to the effect of: <PROJECT>.AssemlyInfo.cs (line xx): error ENC0003: Updating 'attribute' requires restarting the application. as per issue dotnet/sdk#36666. If we've attempted to manually set <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> in the Directory.Build.props that define global properties of all the projects in a solution, the issue is fixed. This issue is not fixed yet when omitting this property. Investigating this further in the https://github.com/dotnet/sourcelink/blob/main/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props file, we've found something interesting. This property list file contains this line: <EnableSourceControlManagerQueries Condition="'$(EnableSourceControlManagerQueries)' == ''">true</EnableSourceControlManagerQueries> For some reason, this property is not being set, causing all sorts of 'attribute' update errors, despite being implicitly set to true in case this property doesn't exist. --- Type: fix Breaking: False Doc Required: False Backport Required: True Part: 1/1
...Reload'ing --- Visual Studio 2022, if you have a project that has Source Link and you attempt to make an edit to any of the kernel code as you debug it without rebuilding it, will go berserk with an error message that says to the effect of: <PROJECT>.AssemlyInfo.cs (line xx): error ENC0003: Updating 'attribute' requires restarting the application. as per issue dotnet/sdk#36666. If we've attempted to manually set <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> in the Directory.Build.props that define global properties of all the projects in a solution, the issue is fixed. This issue is not fixed yet when omitting this property. Investigating this further in the https://github.com/dotnet/sourcelink/blob/main/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props file, we've found something interesting. This property list file contains this line: <EnableSourceControlManagerQueries Condition="'$(EnableSourceControlManagerQueries)' == ''">true</EnableSourceControlManagerQueries> For some reason, this property is not being set, causing all sorts of 'attribute' update errors, despite being implicitly set to true in case this property doesn't exist. --- Type: fix Breaking: False Doc Required: False Backport Required: True Part: 1/1
...Reload'ing --- Visual Studio 2022, if you have a project that has Source Link and you attempt to make an edit to any of the kernel code as you debug it without rebuilding it, will go berserk with an error message that says to the effect of: <PROJECT>.AssemlyInfo.cs (line xx): error ENC0003: Updating 'attribute' requires restarting the application. as per issue dotnet/sdk#36666. If we've attempted to manually set <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> in the Directory.Build.props that define global properties of all the projects in a solution, the issue is fixed. This issue is not fixed yet when omitting this property. Investigating this further in the https://github.com/dotnet/sourcelink/blob/main/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props file, we've found something interesting. This property list file contains this line: <EnableSourceControlManagerQueries Condition="'$(EnableSourceControlManagerQueries)' == ''">true</EnableSourceControlManagerQueries> For some reason, this property is not being set, causing all sorts of 'attribute' update errors, despite being implicitly set to true in case this property doesn't exist. --- Type: fix Breaking: False Doc Required: False Backport Required: True Part: 1/1
...Reload'ing --- Visual Studio 2022, if you have a project that has Source Link and you attempt to make an edit to any of the kernel code as you debug it without rebuilding it, will go berserk with an error message that says to the effect of: <PROJECT>.AssemlyInfo.cs (line xx): error ENC0003: Updating 'attribute' requires restarting the application. as per issue dotnet/sdk#36666. If we've attempted to manually set <EnableSourceControlManagerQueries>true</EnableSourceControlManagerQueries> in the Directory.Build.props that define global properties of all the projects in a solution, the issue is fixed. This issue is not fixed yet when omitting this property. Investigating this further in the https://github.com/dotnet/sourcelink/blob/main/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props file, we've found something interesting. This property list file contains this line: <EnableSourceControlManagerQueries Condition="'$(EnableSourceControlManagerQueries)' == ''">true</EnableSourceControlManagerQueries> For some reason, this property is not being set, causing all sorts of 'attribute' update errors, despite being implicitly set to true in case this property doesn't exist. --- Type: fix Breaking: False Doc Required: False Backport Required: True Part: 1/1
Describe the bug
During Hot Reload, with .NET 7 or .NET 8, building WPF (or Uno Platform) app and hot reloading it in VS 2022 (17.7 or 17.8) can produce the following error:
Where the generated file is
Line 17 being:
Having tried to debug this issue, if feels like the Roslyn HotReload workspace is, for some reason, generating a
AssemblyInformationalVersionAttribute
sometimes:sdk/src/BuiltInTools/dotnet-watch/HotReload/CompilationHandler.cs
Line 69 in 6710347
but since there's no way to get binlogs for the workspace's solution load, it's difficult to troubleshoot why the original value and the hotreloaded values may be different.
To Reproduce
The part being unclear is the set of conditions for this to happen, but here's a summary:
Workaround
Disabling assemblyversion generation helps:
But can cause CA1416 to appear. Disabling
AssemblyFileVersionAttribute
andAssemblyInformationalVersionAttribute
can also help as more precise:sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.GenerateAssemblyInfo.targets
Line 75 in 6710347
Further technical details
Versions
The text was updated successfully, but these errors were encountered: