-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Source generator not running on build when imported from nuget #52427
Comments
@chsienki FYI |
@AlexMacocian Do you have a repro solution somewhere? I tried building https://github.com/AlexMacocian/WpfExtended/ and swapping out the reference with the nuget package here https://www.nuget.org/packages/WpfExtended.SourceGeneration/ but couldn't get anything to repro. |
@chsienki I tried using the WpfExtended.SourceGeneration nuget in some wpf project. I'll build a test solution and push it to github. I'll post the link once it's there. By not getting anything to repro, do you mean that for you it was functional? Were you able to build and run the test project with the nuget reference? |
@chsienki I've uploaded a test project here: I'm seeing the same issue. I can see the generated attribute both in the Analyzers subdirectory in the Solution Explorer as well as I can navigate to it using CTRL+RightClick in VS2019. I can also navigate to the generated partial class and see the code. No errors are detected. But when I try to build, I get the following errors: Are you able to repro the issue now? |
@chsienki Any update pls? Could you pls try the test above? |
@AlexMacocian Thanks for the project, I'll take a look today and see if I can repro it / figure out whats going on. |
@chsienki Thanks a lot! If there's anything I can do to help, please tell me. I'm sorry I can't provide more info, I tried to figure it out myself but I am kinda stuck and really don't get why it's not working as expected. |
@chsienki This looks like a duplicate of dotnet/wpf#3404 |
@sharwell Wow, thanks! Sorry, I didn't realize this was a duplicate. Thanks a lot for linking it. Adding the following property works for me. <IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation> Please close this issue if you so consider. |
@AlexMacocian duplicates are no problem. glad to hear it's working now! 😄 |
Duplicate of dotnet/wpf#3404 |
Version Used:
NetStandard 2.0 in generator project
Net5.0-windows in consumer project
Microsoft.CodeAnalysis.Analyzers 3.3.2 in generator project
Microsoft.CodeAnalysis.CSharp 3.9.0 in generator project
Langversion preview in both projects
VS Enterprise 16.9.3
Steps to Reproduce:
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
Expected Behavior:
After restarting VS, source generator is active and creates new files. They can be observed in Solution Explorer under the Dependencies/Analyzers/{Analyzer-name}/
When building, these generated files are detected and included in the compilation.
Actual Behavior:
Files are generated and they can be observed in Solution Explorer.
When building the solution, the build fails with error CS0246, type or namespace could not be found.
More info
I'm working on a source generator where you can annotate fields in classes with an attribute and then the generator will build the entire cruft of dependency properties in another file. The implementation works and I've tested it on a test project that imported the generator project directly. Sources are generated and accounted for during compilation.
In the project I'm consuming them now, I'm pulling the generator from nuget. In the IDE, the sources are being generated. I can see the files in Solution Explorer. I can also navigate to them with ctrl+click. Both the attribute source as well as the partial implementation of the class that I used it in are generated. Issue comes when I try to run the project. Msbuild reports that it cannot find the GenerateDependencyPropertyAttribute I use to annotate the fields. VS sees it and I'm able to navigate to it but msbuild doesn't.
I suppose this is probably some mistake in the project configuration but I cannot find any more information about it.
Generator csproj
Consumer csproj
The text was updated successfully, but these errors were encountered: