question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Visual Studio does not reload source generator assemblies when they change on disk

See original GitHub issue

I’m just started writing a source generator, and I’m finding that Visual Studio is caching source generators aggressively, and it’s making it very hard to do iterative development.

This is what I’m having to do to make even small changes.

  • Close Visual Studio (devenv.exe) instance in which the source generator project and its consumer (i.e., the project that ProjectReference’s the source generator)
  • pskill /t servicehub.roslyncodeanalysisservice
  • del $env:TEMP\VS\AnalyzerAssemblyLoader -Recurse -Force <- This is where the source generator binaries seem to get cached. Both devenv and servicehub.roslyncodeanalysisservice seems to hold handles to files under this location

Am I missing something simple to get the development process working more seamlessly ?

I’m on 5.0.100-rc.2.20473.20 + Visual Studio 2019 Enterprise 16.8.0 Preview 4.0 [30517.14.main

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:42
  • Comments:122 (64 by maintainers)

github_iconTop GitHub Comments

11reactions
AdmiralSnydercommented, Feb 9, 2023

@palpha I completely forgot that i had already released this extension which makes writing source generators with vs and not needing to restart VS all the time a blast: https://marketplace.visualstudio.com/items?itemName=AlexanderGayko.AutoUpdateAssemblyName

7reactions
AdmiralSnydercommented, Jan 3, 2023

well, the problem usually can be solved nicely. but writing the correct source generator in the first place is a pain. i honestly wonder how the good people at MS doing that can stand all the waiting all the time. (or you have magic instantly-loading VS versions? if so, can we please have them, too? 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Source generator with physical files on disk causing ...
I 'm facing two issues now with my project, first is whenever I try to deserialize the json file (additional file) to my...
Read more >
Microsoft.Extensions.Logging.Generators.dll: Could not ...
Please try to right-click your project node(in VS Solution Explorer) > Unload Project > right-click it again > Reload Project. And then click ......
Read more >
Source Generators
A Source Generator is a .NET Standard 2.0 assembly that is loaded by the compiler along with any analyzers. It's usable in environments ......
Read more >
C# Source Generators in Action, by Andrey Dyatlov - YouTube
C# 9 introduced the long-awaited compiler integrated code generation capability. If you 've dreamed of getting rid of thousands of lines of ...
Read more >
Ngen.exe (Native Image Generator) - .NET Framework
The Native Image Generator (Ngen.exe) is a tool that improves the performance of managed applications. Ngen.exe creates native images, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found