dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.74k stars 1.07k forks source link

Implicit references fail transitively #3046

Closed jzabroski closed 5 years ago

jzabroski commented 5 years ago

This issue is effectively the same issue @natemcmaster has reported in https://github.com/aspnet/Docs/issues/9490#issuecomment-442912739 for .NET Core 2.2 -> 3.0 migrations, but the regression goes back to at least 2.1 -> 2.2 upgrades as well:

Preview 1 Known Issue - workaround for NuGet/Home#7342 - projects which do not start with <Project Sdk="Microsoft.NET.Sdk.Web"> will get compiler or runtime errors due to missing Microsoft.AspNetCore.* assemblies. This is most often the case for test projects and class libraries.

Consider the following project structure:

Source
|
 \ WebApi
   |
   \ WebApi.csproj
Tests
|
 \ WebApi.Tests
  |
   \ WebApi.Tests.csproj

and the following definitions for WebApi.csproj and WebApi.Tests.csproj:

WebApi.csproj

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

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <!-- Implicit Version to avoid MSBuild targets warning -->
    <PackageReference Include="Microsoft.AspNetCore.All" />
    <!--<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.3" AllowExplicitVersion="true" />-->
</Project>

WebApi.Tests.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.1" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
  </ItemGroup>
  <ItemGroup>
    <!-- This could really be any ProjectReference that transitively references a metapackage -->
    <ProjectReference Include="..\WebApi\WebApi.csproj" />
  </ItemGroup>
</Project>

If you build the solution, Tests\WebApi.Tests\obj\project.assets.json will show references to Microsoft.AspNetCore.All metapackage for .NET Core 2.1

The only solution is to use AllowExplicitVersion="true":

<PackageReference Include="Microsoft.AspNetCore.All" Version="2.2.3" AllowExplicitVersion="true" />

The error message is:

Severity: Error     
Code: CS1705
Description: Assembly 'WebApi' with identity 'WebApi, Version=1.5.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.AspNetCore.Mvc.ViewFeatures' with identity 'Microsoft.AspNetCore.Mvc.ViewFeatures, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
Project: WebApi.Tests
File: D:\source\John.Zabroski\Source\WebApi.Tests\CSC
Line:    1
Suppression State: Active
livarcocc commented 5 years ago

@dsplaisted can you take a look?

jzabroski commented 5 years ago

It looks like another possible fix is FrameworkReference, per Nate McMaster. Still, not ideal.

dsplaisted commented 5 years ago

@jzabroski This scenario will be fixed in .NET Core 3.0, which will use FrameworkReferences which will flow transitively.

For 2.2, the ASP.NET Core PackageReference does not flow transitively. However, you should be able to add it to the test project (without a version number, the same as in the web project), and it should work correctly. Have you tried that?

jzabroski commented 5 years ago

@dsplaisted That worked but it's a bit ugly to have to directly include the dependency. I guess it's not much different from how the world worked 4 years ago, so can't complain too much.

Just wondering why this happens so often, and why I'm the one who catches things like this?

One logical reason could be that I define a "cleanfull" target in all my .NET Core projects that does the following:

PS D:\source\John.Zabroski> .\b.ps1 cleanfull
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

  Clean: Configuration=[Release] Platform=[Any CPU] SolutionOrProjectFile=[D:\source\John.Zabroski\Source
  /MySolution.sln]
  Clean: Removing NuGet packages directory
  Clean: Removing MSTest results directory
  Clean: Removing bin and obj directories

This plus an integration test would seem to solve a lot of issues. I'm not trying to give people grief, but I wonder how much time would be saved across Microsoft (and outside Microsoft by its customers!) if such automation existed.

jzabroski commented 5 years ago

@dsplaisted Can you please review my updated Docs pull request? https://github.com/aspnet/Docs/pull/11688 I tried to incorporate your guidance. I left out stuff about FrameworkReference in 3.0 in case that decision changes before final release.

dsplaisted commented 5 years ago

The transitivity issue isn't related to whether your project is clean. It's just how the reference to ASP.NET works in .NET Core 2.2.

We've been iterating on how the ASP.NET dependency is expressed since .NET Core 1.0. While not ideal, the behavior in 2.2 is improved over 2.1, 2.0, etc. We've made some more fundamental changes for .NET Core 3.0, which we believe will be a big improvement and resolve the issues we've had in previous versions with how the ASP.NET dependency works.

jzabroski commented 5 years ago

@dsplaisted Updated original post to reflect my full understanding of the issue.

jzabroski commented 5 years ago

It seems there are two possible positive test cases:

I'll omit negative test cases here, as we don't seem to know the root cause yet. However, the above positive test cases call attention to the fact https://docs.microsoft.com/en-us/dotnet/core/tools/csproj does not cover how <Project Sdk="X"> values for X may or may not influence metapackages.

jzabroski commented 5 years ago

@dsplaisted Is it possible dotnet host roll forward could be causing you to have difficulty reproducing my issue? How do I share my settings with you? I've just been going through documentation on .NET Core to fully understand what all the knobs are and how they work. See: https://github.com/aspnet/Docs/blob/master/aspnetcore/fundamentals/metapackage-app.md

Quote:

Specifying a version number on the Microsoft.AspNetCore.App reference does not guarantee that version of the shared framework will be chosen. For example, suppose version "2.1.1" is specified, but "2.1.3" is installed. In that case, the app will use "2.1.3". Although not recommended, you can disable roll forward (patch and/or minor). For more information regarding dotnet host roll-forward and how to configure its behavior, see dotnet host roll forward.

So, at compile-time in Visual Studio, you (probably) need to account for whether the user has specified DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX. (I do not have it set, since running $env:DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX in PowerShell Core returns $null).

It also seems the Visual Studio About dialog needs a refresh so that we can consistently nail down why I have this issue you cannot reproduce.

In my case, I have the following Visual Studio "things" installed - but it doesn't list what targeting packs and SDKs I have installed, so you can't really diagnose what roll forward conditions I have:

John Zabroski's Visual Studio Professional 2017 Version 15.9.10 Copy Info Microsoft Visual Studio Professional 2017 Version 15.9.10 VisualStudio.15.Release/15.9.10+28307.557 Microsoft .NET Framework Version 4.7.03056 Installed Version: Professional Visual C++ 2017 00370-10200-04083-AA740 Microsoft Visual C++ 2017 ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools AnkhSVN - Subversion Support for Visual Studio 2.7.12815.35086 AnkhSVN - Subversion Support for Visual Studio 2.7.12815.35086 * Ankh.Package 2.7.12815.35086 * Subversion 1.9.5 via SharpSvn 1.9005.3940.224 * Git/LibGit2 0.24.0 via SharpGit 0.2401.1116.230 SharpSvn is linked to: Apr 1.5.2, Apr-util 1.5.4, Cyrus Sasl 2.1.26, eXpat 2.2.0, LibSSH2 1.8.0, OpenSSL 1.0.2k 26 Jan 2017, Serf 1.3.9, SQLite 3.17.0, Subversion 1.9.5-SharpSvn, Utf8proc 1.1.5, ZLib 1.2.8 SharpSvn is optionally linked to: Berkeley DB 4.4.20, SharpPlink 0.67.0(SharpSvn) SharpGit is linked to: Apr 1.5.1, Apr-Util 1.5.4, eXpat 2.1.0, Libgit2 0.24.0, LibSSH2 1.7.0, OpenSSL 1.0.2h 3 May 2016, Subversion 1.9.3, Utf8proc 1.1.5, ZLib 1.2.8 Application Insights Tools for Visual Studio Package 8.14.20131.1 Application Insights Tools for Visual Studio ASP.NET and Web Tools 2017 15.9.04012.0 ASP.NET and Web Tools 2017 ASP.NET Core Razor Language Services 15.8.31590 Provides languages services for ASP.NET Core Razor. ASP.NET Web Frameworks and Tools 2017 5.2.60913.0 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 15.9.03024.0 Azure App Service Tools v3.0.0 Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer. Azure Data Lake Tools for Visual Studio 2.3.7000.2 Microsoft Azure Data Lake Tools for Visual Studio Azure Stream Analytics Tools for Visual Studio 2.3.7000.2 Microsoft Azure Stream Analytics Tools for Visual Studio C# Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Cookiecutter 15.9.18254.1 Provides tools for finding, instantiating and customizing templates in cookiecutter format. Devart Code Compare 5.0.85 Devart Code Compare Copyright (c) 2012-2017 Devart. All rights reserved. http://www.devart.com/codecompare/ JavaScript Language Service 2.0 JavaScript Language Service JavaScript Project System 2.0 JavaScript Project System JavaScript UWP Project System 2.0 JavaScript UWP Project System JetBrains ReSharper Ultimate 2018.2.3 Build 182.0.20180912.70621 JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2019 JetBrains, Inc. Microsoft Azure HDInsight Azure Node 2.3.7000.2 HDInsight Node under Azure Node Microsoft Azure Hive Query Language Service 2.3.7000.2 Language service for Hive query Microsoft Azure Stream Analytics Language Service 2.3.7000.2 Language service for Azure Stream Analytics Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.0.0 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft Library Manager 1.0 Install client-side libraries easily to any web project Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container. Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package MLGen Package Extension 1.0 MLGen Package Visual Studio Extension Detailed Info NuGet Package Manager 4.6.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/. PowerShell Pro Tools for Visual Studio 1.0 A set of tools for developing and debugging PowerShell scripts and modules in Visual Studio. ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info Python 15.9.18254.1 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers. Python - Django support 15.9.18254.1 Provides templates and integration for the Django web framework. Python - IronPython support 15.9.18254.1 Provides templates and integration for IronPython-based projects. Python - Profiling support 15.9.18254.1 Profiling support for Python projects. R Tools for Visual Studio 1.3.40517.1016 Provides project system, R Interactive window, plotting, and more for the R programming language. Redgate SQL Prompt 9.4.14.8687 Write, format, and refactor SQL effortlessly ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info SQL Server Data Tools 15.1.61903.01040 Microsoft SQL Server Data Tools SQL Server Reporting Services 15.0.1300.90 Microsoft SQL Server Reporting Services Designers Version 15.0.1300.90 ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript Tools 15.9.20918.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 10.2 for F# 4.5 15.8.0.0. Commit Hash: 6e26c5bacc8c4201e962f5bdde0a177f82f88691. Microsoft Visual F# Tools 10.2 for F# 4.5 Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers Visual Studio Tools for Universal Windows Apps 15.0.28307.556 The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

And here is my dotnet.exe diagnostics:

PS D:\source\GitHub\FluentValidation> dotnet.exe --list-runtimes
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
PS D:\source\GitHub\FluentValidation> dotnet.exe --list-sdks
1.0.4 [C:\Program Files\dotnet\sdk]
2.0.2 [C:\Program Files\dotnet\sdk]
2.0.3 [C:\Program Files\dotnet\sdk]
2.1.2 [C:\Program Files\dotnet\sdk]
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.100 [C:\Program Files\dotnet\sdk]
2.1.101 [C:\Program Files\dotnet\sdk]
2.1.103 [C:\Program Files\dotnet\sdk]
2.1.104 [C:\Program Files\dotnet\sdk]
2.1.200 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.400 [C:\Program Files\dotnet\sdk]
2.1.401 [C:\Program Files\dotnet\sdk]
2.1.402 [C:\Program Files\dotnet\sdk]
2.1.403 [C:\Program Files\dotnet\sdk]
2.1.500 [C:\Program Files\dotnet\sdk]
2.1.502 [C:\Program Files\dotnet\sdk]
2.1.503 [C:\Program Files\dotnet\sdk]
2.1.504 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.2.105 [C:\Program Files\dotnet\sdk]
PS D:\source\GitHub\FluentValidation> dotnet.exe --version
2.2.105
PS D:\source\GitHub\FluentValidation>
jzabroski commented 5 years ago

@dsplaisted I built a brand new machine, I put together a full repro of the issue, but noticed some oddities while trying to reproduce the issue. In this case, your guidance to explicitly include an implicitly referenced metapackage without version in the transitive project fails. Here are the errors - I will upload my full repro sln to GitHub for you to look into.

Severity: Error
Code: CS1705
Description: Assembly 'WebApi' with identity 'WebApi, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.AspNetCore.Mvc.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' which has a higher version than referenced assembly 'Microsoft.AspNetCore.Mvc.Core' with identity 'Microsoft.AspNetCore.Mvc.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
Project: WebApi.Tests
File: D:\source\GitHub\ImplicitReferencesFailTransitively\Sample\WebApi.Tests\CSC
Line: 1
Suppression State: Active

Severity: Warning
Code: MSB3277
Description: Found conflicts between different versions of "Microsoft.AspNetCore.Hosting.Abstractions" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
Project: WebApi.Tests
File: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets
Line: 2110

Severity: Warning
Code: MSB3277
Description: Found conflicts between different versions of "Microsoft.AspNetCore.Http.Abstractions" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
Project: WebApi.Tests
File: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets
Line: 2110

Severity: Warning
Code: MSB3277
Description: Found conflicts between different versions of "Microsoft.AspNetCore.Mvc.Core" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.    Project: WebApi.Tests
File: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets
Line: 2110  

Severity: Warning
Code: NU1604
Description: Project dependency Microsoft.AspNetCore.Mvc.Core does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
Project: WebApi.Tests
File: D:\source\GitHub\ImplicitReferencesFailTransitively\Sample\WebApi.Tests\WebApi.Tests.csproj
Line:1  

Debug Context

MSBuild targets

Get-FileHash of the targets file generating the error, to make sure you and I are comparing apples to apples.

PS C:\Users\john.zabroski> get-filehash "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets"

Algorithm       Hash                                                                   Path
---------       ----                                                                   ----
SHA256          0E21AE69F27137BE03D4E94F750B2BCDE542CFE2C0F56ACCA8CF277DA6438BF5       C:\Program Files (x86)\Micros...

DotNet dependencies

Here are my new machines dotnet.exe sdks, version, etc. I noticed one oddity here - dotnet.exe file version metadata and --version disagree!

PS C:\Users\john.zabroski> dotnet.exe --list-runtimes
Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
PS C:\Users\john.zabroski> dotnet.exe --list-sdks
1.1.13 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.505 [C:\Program Files\dotnet\sdk]
2.2.105 [C:\Program Files\dotnet\sdk]
PS C:\Users\john.zabroski> get-command dotnet.exe

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     dotnet.exe                                         2.2.274... C:\Program Files\dotnet\dotnet.exe

PS C:\Users\john.zabroski> dotnet.exe --version
2.2.105

PS C:\Users\john.zabroski> $env:DOTNET_ROLL_FORWARD_ON_NO_CANDIDATE_FX -eq $null
True

Visual Studio dependencies

Here are my Visual Studio Help About Copy Info

John Zabroski Visual Studio 2017 Copy Info Microsoft Visual Studio Professional 2017 Version 15.9.10 VisualStudio.15.Release/15.9.10+28307.557 Microsoft .NET Framework Version 4.7.03190 Installed Version: Professional Visual C++ 2017 00369-60000-00001-AA382 Microsoft Visual C++ 2017 ADL Tools Service Provider 1.0 This package contains services used by Data Lake tools Application Insights Tools for Visual Studio Package 8.14.20131.1 Application Insights Tools for Visual Studio ASP.NET and Web Tools 2017 15.9.04012.0 ASP.NET and Web Tools 2017 ASP.NET Core Razor Language Services 15.8.31590 Provides languages services for ASP.NET Core Razor. ASP.NET Web Frameworks and Tools 2012 4.0.30625.0 For additional information, visit https://www.asp.net/ ASP.NET Web Frameworks and Tools 2017 5.2.60913.0 For additional information, visit https://www.asp.net/ Azure App Service Tools v3.0.0 15.9.03024.0 Azure App Service Tools v3.0.0 Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer. Azure Data Lake Tools for Visual Studio 2.3.8000.0 Microsoft Azure Data Lake Tools for Visual Studio Azure Functions and Web Jobs Tools 15.9.02046.0 Azure Functions and Web Jobs Tools Azure Stream Analytics Tools for Visual Studio 2.3.8000.0 Microsoft Azure Stream Analytics Tools for Visual Studio C# Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Cookiecutter 15.9.18254.1 Provides tools for finding, instantiating and customizing templates in cookiecutter format. Dotfuscator Community Edition 5.36.0.7050-e77ce80a6 PreEmptive Protection - Dotfuscator CE Extensibility Message Bus 1.1.49 (remotes/origin/d15-8@ee674f3) Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration. Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events GitHub.VisualStudio 2.6.0.6193 A Visual Studio Extension that brings the GitHub Flow into Visual Studio. IncrediBuild Build Acceleration 1.5.0.3 IncrediBuild effectively reduces compilation and development times by up to 90%. JavaScript Language Service 2.0 JavaScript Language Service JavaScript Project System 2.0 JavaScript Project System JavaScript UWP Project System 2.0 JavaScript UWP Project System JetBrains ReSharper Ultimate 2018.3.4 Build 183.0.20190304.43214 JetBrains ReSharper Ultimate package for Microsoft Visual Studio. For more information about ReSharper Ultimate, visit http://www.jetbrains.com/resharper. Copyright © 2019 JetBrains, Inc. Microsoft Azure HDInsight Azure Node 2.3.8000.0 HDInsight Node under Azure Node Microsoft Azure Hive Query Language Service 2.3.8000.0 Language service for Hive query Microsoft Azure Service Fabric Tools for Visual Studio 2.4 Microsoft Azure Service Fabric Tools for Visual Studio Microsoft Azure Stream Analytics Language Service 2.3.8000.0 Language service for Azure Stream Analytics Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.0.0 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE. Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines Microsoft Library Manager 1.0 Install client-side libraries easily to any web project Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container. Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package MLGen Package Extension 1.0 MLGen Package Visual Studio Extension Detailed Info Mono Debugging for Visual Studio 4.13.12-pre (9bc9548) Support for debugging Mono processes with Visual Studio. Node.js Tools 1.4.21001.1 Commit Hash:8dd15923800d931b153ab9e4de74e42a74eba5e6 Adds support for developing and debugging Node.js apps in Visual Studio NuGet Package Manager 4.6.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/. Office Developer Tools for Visual Studio 2017 ENU 15.0.28224.00 Microsoft Office Developer Tools for Visual Studio 2017 ENU ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info Python 15.9.18254.1 Provides IntelliSense, projects, templates, debugging, interactive windows, and other support for Python developers. Python - Django support 15.9.18254.1 Provides templates and integration for the Django web framework. Python - IronPython support 15.9.18254.1 Provides templates and integration for IronPython-based projects. Python - Profiling support 15.9.18254.1 Profiling support for Python projects. Python - UWP support 15.9.18254.1 Provides templates and integration for the UWP framework. Python - VC Project Support 15.8.18116.3 Provides support for launching C++ projects with Python debugging enabled. R Tools for Visual Studio 1.3.40517.1016 Provides project system, R Interactive window, plotting, and more for the R programming language. Redgate SQL Prompt 9.4.15.8960 Write, format, and refactor SQL effortlessly ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info SQL Server Data Tools 15.1.61903.01040 Microsoft SQL Server Data Tools Syntax Visualizer 1.0 An extension for visualizing Roslyn SyntaxTrees. Test Adapter for Boost.Test 1.0 Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory. Test Adapter for Google Test 1.0 Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory. ToolWindowHostedEditor 1.0 Hosting json editor into a tool window TypeScript Tools 15.9.20918.2001 TypeScript Tools for Microsoft Visual Studio Visual Basic Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual C++ for Cross Platform Mobile Development (Android) 15.0.28107.00 Visual C++ for Cross Platform Mobile Development (Android) Visual C++ for Linux Development 1.0.9.28218 Visual C++ for Linux Development Visual F# Tools 10.2 for F# 4.5 15.8.0.0. Commit Hash: 6e26c5bacc8c4201e962f5bdde0a177f82f88691. Microsoft Visual F# Tools 10.2 for F# 4.5 Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio Visual Studio Tools for Apache Cordova 15.123.7408.1 Visual Studio Tools for Apache Cordova Visual Studio Tools for CMake 1.0 Visual Studio Tools for CMake Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers Visual Studio Tools for Unity 3.9.0.3 Visual Studio Tools for Unity Visual Studio Tools for Universal Windows Apps 15.0.28307.556 The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit. VisualStudio.Mac 1.0 Mac Extension for Visual Studio Workflow Manager Tools 1.0 1.0 This package contains the necessary Visual Studio integration components for Workflow Manager. Xamarin 4.12.3.81 (d15-9@780082716) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 4.16.13 (45a16efd4) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 1.1.128 (6f5ebb2) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 9.1.7.0 (HEAD/ba9da7a76) Xamarin.Android Reference Assemblies and MSBuild support. Xamarin.iOS and Xamarin.Mac SDK 12.2.1.16 (2dc06c7) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
jzabroski commented 5 years ago

@dsplaisted https://github.com/jzabroski/ImplicitReferencesFailTransitively Good luck :)

dsplaisted commented 5 years ago

@jzabroski I was finally able to take a look at your repro. The issue is that only Microsoft.AspNetCore.App and Microsoft.AspNetCore.All are supported as versionless package references. In your test project, you have <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" />. Replace this with <PackageReference Include="Microsoft.AspNetCore.App" />, and it should build successfully.

jzabroski commented 5 years ago

Good catch... I think Resharper may have automatically added a PackageReference for me when it detected I was referencing an MVC Controller.

Sorry, I did not mean to waste your time with the repro - was trying if anything to save you effort. Ah, the art of a good repro :)

As an aside, I am a little perplexed - now if I comment out <PackageReference Include="Microsoft.AspNetCore.App" /> everything just works, even after cleaning my bin and obj directories. I'm completely turned around right now.

I'm on 15.9.10 now.

dsplaisted commented 5 years ago

If I comment out that PackageReference in your repro, I get the following error:

UnitTest1.cs(12,25): error CS0012: The type 'ControllerBase' is defined in an assembly that is not referenced. You must add a reference to assembly 'Microsoft.AspNetCore.Mvc.Core, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

jzabroski commented 5 years ago

Thanks. That is what I saw before, and am not seeing now. I might just need an eye doctor appointment... 👓

cfguimaraes commented 5 years ago

This issues can be closed?

jzabroski commented 5 years ago

@cfguimaraes Agreed, on .NET SDK 2.2, if I change my reference from <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" /> to <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="[2.2.0,)" /> Then warning goes away. I also no longer get a warning about using a FrameworkReference instead.

Similarly, if I then add <TargetFrameworks>netcoreapp2.2;netcoreapp3.0</TargetFrameworks> I get the error message:

Severity    Code    Description Project File    Line    Suppression State
Error   NETSDK1045  The current .NET SDK does not support targeting .NET Core 3.0.  Either target .NET Core 2.2 or lower, or use a version of the .NET SDK that supports .NET Core 3.0. WebApi.Tests    C:\Program Files\dotnet\sdk\2.2.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets   137 

(@dsplaisted @nguerrera Really great error message, btw! You and your team NAILED IT down to the last detail of creating a separate MSBuild targets file so that the user doesn't even have to click into the file to understand the error is with "TargetFrameworkInference"!)