-
Notifications
You must be signed in to change notification settings - Fork 94
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
Workaround for WPF PackageReference and source generators bug #7
Comments
I believe I'm running into some form of this issue with a package that contains C# files in its |
@nick-beer, your question sounds unrelated to this source generator and more appropriate for the WPF audience. Can you try posting your question over on the dotnet/wpf repo? |
@AArnott - Shoot, I'm sorry. I'm not sure what repo I thought I was in - I just followed google from a search for |
Hello, we're trying to use CsWin32 with our .NET 5.0 WPF app and the steps above DO NOT work (we followed them exactly). We still continue to get the following error. What are we missing?
Thanks in advance! |
@anti-matter, I have attached a .zip to a sample that works in our testing to the issue description. Does that work on your machine with |
Thanks @AArnott for the zip. That simple project works fine for me, but I still cannot get it to work in my project. I tried to find a setting that our project has set that might be causing our build to fail, but no luck. I did notice too that intellisense still claims there's an error with Microsoft.Windows.SDK in the sample project, but the compiler seems to ignore that it's missing. In my case, the compiler does not ignore it. Is there a release where we expect this issue to be resolved in WPF so the work-around is not necessary? thx. |
The compiler can't and isn't ignoring it. The compiler sees it where the IDE language service does not. So given the sample project works for you at the command line but your project does not work at the command line tells us that there is something peculiar with your project that prevents the source generator from running. I suggest you compare the build logs between the sample and your project. Use the Once you get the command line build working on your project, we can focus on what remains in the IDE that could be broken, but you should probably start with trying out 16.9 Preview 3 to see if that works for you, as a lot of source generator bugs have been fixed in that release.
The fix is already released, but it requires opt-in via the property documented above. |
Ok, thanks @AArnott, I think we figured it out. In the sample, the using path is Microsoft.Windows.SDK, but for some reason, in our project, it must be Microsoft.Windows.Sdk. Using that camel case seems to have fixed our issue. Such a small thing. :) |
@anti-matter What sample uses |
@AArnott does this fix apply to WPF non-core (WPF framework?)? i.e.
I didn't see the property when searched the |
@inthemedium, I'm told that it should work, provided you are building with the required SDK version.
Then something else is wrong, since you are setting the property, it should be there. |
@AArnott , figured out the issue. I needed to add
|
It seems to be fixed in dotnet 6. |
True. The .NET 6 SDK includes the new behavior as on by default whereas .NET 5 SDK had it off by default. |
If anyone has this problem in .NET 6, try to install |
@zhylmzr, that's quite an old version of CsWin32. Do you find it works better than the latest version? |
@AArnott The newst version doesn't work in my environment, same error message. |
Does anyone have a fix for this in .NET 6? I have a WPF project but receive the following when compiling:
Where the namespace and type is defined in my Source generator. This had no issues in .net 472 with SDK style project, but have recently upgraded. The project has the following tags:
|
When developing a WPF project, dotnet/wpf#810 and dotnet/wpf#3963 will cause the WPF "inner build" to omit important elements to source generators, leading to build breaks anywhere you use the generated code as reported by a
*_wpftmp.csproj
project file.For example you may see a compiler error as if the generated types do not exist:
To fix this you must use the .NET 5.0.102 SDK and set the following property in your project:
To make sure you are using the SDK with the fix, you may need to add a
global.json
file with this content to the root of your repo:Here is a fully working minimal sample: wpfsample.zip
The text was updated successfully, but these errors were encountered: