dotnet / project-system

The .NET Project System for Visual Studio
MIT License
968 stars 386 forks source link

Incorrect warning icons when ReferenceOutputAssembly="false" #2928

Closed jnm2 closed 4 years ago

jnm2 commented 6 years ago

Whenever I use ReferenceOutputAssembly="false", no matter what the target framework is (even between csproj and wixproj), I get a warning symbol even though there are no build warnings:

image

In this instance:

ClassLibrary1.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net462</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\ClassLibrary2\ClassLibrary2.csproj" ReferenceOutputAssembly="false" />
  </ItemGroup>

</Project>

ClassLibrary2.csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net462</TargetFramework>
  </PropertyGroup>

</Project>
natidea commented 6 years ago

DevNotes: with ReferenceOutputAssembly="false", NuGet does not generate a project reference in the assets file:

      "frameworks": {
        "netstandard2.0": {
          "projectReferences": {}
        }
      },

This likely means a ResolvedProjectReference item is not produced. However this does not seem to be a problem in Microsoft.NET.Build.Extensions.Tasks.csproj which resolves its project reference correctly. Investigating further...

evgeny-burmakov commented 6 years ago

Do we have any workaround for hiding icon or reference?

evgeny-burmakov commented 5 years ago

Any news?

evgeny-burmakov commented 5 years ago

I have tried Dev 16 Preview and behavior is still observed. Any plans to fix it at upcoming version?

drewnoakes commented 5 years ago

@evgeny-burmakov thanks for your patience. It's definitely on the radar. This issue will be updated as soon as there is any progress.

ReubenBond commented 5 years ago

I believe this is the reason why we see warning icons in VS in Orleans. We use a ProjectReference with SkipGetTargetFrameworkProperties set in order to ensure correct build order (codegen must be built before projects which rely on it).

image

If I add a condition '$(DesignTimeBuild) != '' to the ProjectReference then the warning icon (and dependency) disappears but build inside VS fails.

image

davkean commented 5 years ago

Haven't tried, but Visible on the reference should be respected. If not, that's probably a different bug.

ReubenBond commented 5 years ago

Visible does hide the project, but the warning icon on the Dependencies node remains

davkean commented 5 years ago

@drewnoakes This will be a case of dependency node expecting a counterpart design-time builds result for the item it finds in evaluation.

drewnoakes commented 5 years ago

Seems likely. I'll test my repro solution for this issue as part of the work I'm doing on #4550.

jhudsoncedaron commented 4 years ago

We track this issue. Same ultimate cause: project has a special build step which causes it to need a non-build dependency on another project. Useless visual studio warning icon with no actual warning.

davidwengier commented 4 years ago

The established norm for referencing source generators as a project reference is to use OutputItemType="Analyzer" ReferenceOutputAssembly="false" so hits for this could start to increase with .NET 5. I mention this mainly so that searching for "Source Generator" correctly finds this issue, and because I happen to be using source generators a bunch at the moment 😁

dmonroym commented 4 years ago

Related to https://github.com/dotnet/msbuild/issues/1916

drewnoakes commented 4 years ago

A fix for this issue has been merged and will be released as part of 16.8.