-
Notifications
You must be signed in to change notification settings - Fork 4
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
Duplicate definition error in VS 2022 #10
Comments
This also doesn't work in VS 2022 for <ItemGroup Condition="'$(TargetFramework)'=='netcoreapp3.1'">
<PackageReference Include="IsExternalInit" Version="1.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
|
Hey, I tried to reproduce the issue, but cannot, at the moment. I created a new console app, added the package and the following code: Console.WriteLine(new Message("Hello, World!"));
public record Message(string Mesage); So far, everything works on my side. I successfully ran it using the Could you maybe upload a minimal example project which causes issues for you? Thanks a lot! |
@manuelroemer Could you please create alpha/beta package with fix proposed by topic starter (see 1st line of this file) and I'll test it on this project. |
We're multi targeting .net framework 4.5.2, 4.8 and .net core 3.1. I can't do more testing at the moment because I had to uninstall VS 2022 since it also broke the builds on VS 2019. |
I installed the .NET 6 SDK (no VS 2022 yet) and this makes my compilation fail as well. The project is a WPF project ( Looks like they changed something in .NET 6, see dotnet/wpf#810 |
Yeah, it seems like something in the SDK/tooling changed/got broken. In any case, if something is wrong with the SDK, there is not much I can do at the moment. I also don't have any time for investigating where the issue is rooted. Either someone else has an idea/makes a PR for this repo or the issue gets fixed upstream by the .NET guys.
@SWeini That's an interesting clue, thanks a lot! Just to clarify, do you mean these definitions here? If these are an issue, we could maybe remove them altogether (I think the issue that they worked around was eventually fixed in some .NET 5 SDK update). |
@manuelroemer It doesn't compile with new package out of the box. Looks like |
|
We could also remove the .targets files completely. That's how the issue seems to be solved in https://github.com/manuelroemer/Nullable If you want to be backwards-compatible to SDKs before .NET 5 you might still need that workaround. I haven't tested this with all possible versions.
|
Yes, I think that removing the workaround is the best course of action. And I think the assumption that users have an up-to-date SDK (be it .NET 5 or .NET6+) is reasonable enough. Would you like to make this change in your PR? Would be much appreciated! 🍻 |
Could you upload package for testing, please? |
You mean with the change proposed by @SWeini? If so, yes, I'd upload a prerelease for testing before creating a "full" release. |
@manuelroemer sorry for bumping this, but what's the plan now? I see there's a PR waiting for approval, is there anything that needs to be done? |
No worries, bumping is more than fair here! I merged #11 and uploaded the next prerelease version for testing: https://www.nuget.org/packages/IsExternalInit/1.0.2-pre2 If that still doesn't make things work, my last remaining hope is to revert #5 and #6, but ideally we can avoid that. |
@manuelroemer can confirm it works for me now 👍 |
Will the fix be released as a proper version 1.0.2 or do we keep the 1.0.2-pre2 tag? Just so I know when to merge back into master in our code base :) |
Works for me. |
I'll release a 1.0.2 very soon! |
Done. Thanks to all of you for helping resolve this issue! |
Thanks for providing and updating the package! |
I think we've broken the old behavior now. If you try to use the new nuget package without having .net 6 sdk installed (but rather .net 5 sdk), builds break on VS 2019 with the same error
|
Ok it looks like it's not really broken, but the behavior changed a bit. Previously, we were able to just reference the nuget package (with .net 5) and it just worked. But now we also have to add
to make it work with .net 5. So now I can confirm it works with .net 6 as well as .net 5. Sorry for the confusion 😅 |
@manuelroemer 1.0.1 is still the newest version on nuget.org. Was the 1.0.2 pulled, or something? |
https://www.nuget.org/packages/IsExternalInit/1.0.2 It was unlisted for some reason. Now it's back. |
Hey, as @i2van said, it was unlisted, probably by accident when I unlisted the prerelease versions. In any case the full 1.0.2 is back now. |
I'm trying to upgrade my solution to VS 2022, but if I build it I'm getting duplicate definition errors that weren't there before with VS 2019. I guess this is caused by the new .net 6 sdk?
I think a simple future proof fix would be to wrap the source code in another #if block
since
NET
is defined for .net 5 and later.The text was updated successfully, but these errors were encountered: