Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Visual Studio design time build failing to recognize essential types like Void, IDisposable, Enum in test code #68862

Closed
carlossanlop opened this issue May 4, 2022 · 6 comments

Comments

@carlossanlop
Copy link
Member

carlossanlop commented May 4, 2022

@ViktorHofer

It seems a recent change broke design time build for test code in Visual Studio. Not sure if widespread or not, but I can repro this in System.Formats.Tar:

  • Sync your local clone to the latest bits in main.
  • Clean with git clean -fdx.
  • Build with build.cmd clr+libs -rc release.
  • Open the solution with build.cmd -vs System.Formats.Tar.
  • Open any test file.
  • Notice the red squiggle error messages, they say we cannot find System.Void, System.IDisposable, System.Enum.
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label May 4, 2022
@ghost
Copy link

ghost commented May 4, 2022

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Issue Details

@ViktorHofer

It seems a recent change broke design time build for test code in Visual Studio. Not sure if widespread or not, but I can repro this in System.Formats.Tar:

  • Sync your local clone to the latest bits in main
  • Build with build.cmd clr+libs -rc release
  • Open the solution with build.cmd -vs System.Formats.Tar
  • Open any test file.
  • Notice the red squiggle error messages, they say we cannot find System.Void, System.IDisposable, System.Enum.
Author: carlossanlop
Assignees: -
Labels:

area-Infrastructure-libraries

Milestone: -

@ViktorHofer
Copy link
Member

ViktorHofer commented May 4, 2022

That's because you have a ProjectReference to the source project even though the source assembly is already referenced as part of the live built microsoft.netcore.app.ref targeting pack:

<ItemGroup>
<ProjectReference Include="..\src\System.Formats.Tar.csproj" />
</ItemGroup>

When you remove that ProjectReference, the design time build failures go away. You can see in the design time binlog that the reference assembly is chosen from the ProjectReference's output folder:

image

@ViktorHofer ViktorHofer added this to the 7.0.0 milestone May 4, 2022
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label May 4, 2022
@ViktorHofer ViktorHofer added untriaged New issue has not been triaged by the area owner and removed untriaged New issue has not been triaged by the area owner labels May 4, 2022
@carlossanlop
Copy link
Member Author

Thanks, that fixed it.

@ViktorHofer
Copy link
Member

ViktorHofer commented May 4, 2022

cc @ericstj as you might be interested in this. Seems there is a conflict between P2Ps when the assembly is also exposed inbox (via the targeting pack).

@ericstj
Copy link
Member

ericstj commented May 4, 2022

yeah, that's not handled well in the SDK: dotnet/sdk#2674

It might be nice if our infrastructure did some validation around what sort of reference to use where. Guide people down the path of doing the right thing.

@ViktorHofer
Copy link
Member

ViktorHofer commented May 5, 2022

It might be nice if our infrastructure did some validation around what sort of reference to use where. Guide people down the path of doing the right thing.

This already works for a normal build because of

<_targetingPackReferenceExclusion Include="@(_ResolvedProjectReferencePaths->Metadata('Filename'))" />

It might make more sense to investigate why this doesn't work for a design time build.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

3 participants