-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implicit references fail transitively #3046
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
Comments
@dsplaisted can you take a look? |
It looks like another possible fix is FrameworkReference, per Nate McMaster. Still, not ideal. |
@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? |
@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. |
@dsplaisted Can you please review my updated Docs pull request? dotnet/AspNetCore.Docs#11688 I tried to incorporate your guidance. I left out stuff about FrameworkReference in 3.0 in case that decision changes before final release. |
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. |
@dsplaisted Updated original post to reflect my full understanding of the issue. |
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 |
@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:
So, at compile-time in Visual Studio, you (probably) need to account for whether the user has specified 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 InfoMicrosoft Visual Studio Professional 2017 Version 15.9.10 VisualStudio.15.Release/15.9.10+28307.557 Microsoft .NET Framework Version 4.7.03056Installed Version: Professional Visual C++ 2017 00370-10200-04083-AA740 ADL Tools Service Provider 1.0 AnkhSVN - Subversion Support for Visual Studio 2.7.12815.35086
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 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 ASP.NET and Web Tools 2017 15.9.04012.0 ASP.NET Core Razor Language Services 15.8.31590 ASP.NET Web Frameworks and Tools 2017 5.2.60913.0 Azure App Service Tools v3.0.0 15.9.03024.0 Azure Data Lake Node 1.0 Azure Data Lake Tools for Visual Studio 2.3.7000.2 Azure Stream Analytics Tools for Visual Studio 2.3.7000.2 C# Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a Common Azure Tools 1.10 Cookiecutter 15.9.18254.1 Devart Code Compare 5.0.85 JavaScript Language Service 2.0 JavaScript Project System 2.0 JavaScript UWP Project System 2.0 JetBrains ReSharper Ultimate 2018.2.3 Build 182.0.20180912.70621 Microsoft Azure HDInsight Azure Node 2.3.7000.2 Microsoft Azure Hive Query Language Service 2.3.7000.2 Microsoft Azure Stream Analytics Language Service 2.3.7000.2 Microsoft Azure Stream Analytics Node 1.0 Microsoft Azure Tools 2.9 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Microsoft JVM Debugger 1.0 Microsoft Library Manager 1.0 Microsoft MI-Based Debugger 1.0 Microsoft Visual C++ Wizards 1.0 Microsoft Visual Studio Tools for Containers 1.1 Microsoft Visual Studio VC Package 1.0 MLGen Package Extension 1.0 NuGet Package Manager 4.6.0 PowerShell Pro Tools for Visual Studio 1.0 ProjectServicesPackage Extension 1.0 Python 15.9.18254.1 Python - Django support 15.9.18254.1 Python - IronPython support 15.9.18254.1 Python - Profiling support 15.9.18254.1 R Tools for Visual Studio 1.3.40517.1016 Redgate SQL Prompt 9.4.14.8687 ResourcePackage Extension 1.0 ResourcePackage Extension 1.0 SQL Server Data Tools 15.1.61903.01040 SQL Server Reporting Services 15.0.1300.90 ToolWindowHostedEditor 1.0 TypeScript Tools 15.9.20918.2001 Visual Basic Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a Visual F# Tools 10.2 for F# 4.5 15.8.0.0. Commit Hash: 6e26c5bacc8c4201e962f5bdde0a177f82f88691. Visual Studio Code Debug Adapter Host Package 1.0 Visual Studio Tools for Containers 1.0 Visual Studio Tools for Universal Windows Apps 15.0.28307.556
|
@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.
Debug ContextMSBuild targets
DotNet dependenciesHere are my new machines
Visual Studio dependenciesHere are my Visual Studio Help About Copy Info John Zabroski Visual Studio 2017 Copy InfoMicrosoft Visual Studio Professional 2017 Version 15.9.10 VisualStudio.15.Release/15.9.10+28307.557 Microsoft .NET Framework Version 4.7.03190Installed Version: Professional Visual C++ 2017 00369-60000-00001-AA382 ADL Tools Service Provider 1.0 Application Insights Tools for Visual Studio Package 8.14.20131.1 ASP.NET and Web Tools 2017 15.9.04012.0 ASP.NET Core Razor Language Services 15.8.31590 ASP.NET Web Frameworks and Tools 2012 4.0.30625.0 ASP.NET Web Frameworks and Tools 2017 5.2.60913.0 Azure App Service Tools v3.0.0 15.9.03024.0 Azure Data Lake Node 1.0 Azure Data Lake Tools for Visual Studio 2.3.8000.0 Azure Functions and Web Jobs Tools 15.9.02046.0 Azure Stream Analytics Tools for Visual Studio 2.3.8000.0 C# Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a Common Azure Tools 1.10 Cookiecutter 15.9.18254.1 Dotfuscator Community Edition 5.36.0.7050-e77ce80a6 Extensibility Message Bus 1.1.49 (remotes/origin/d15-8@ee674f3) Fabric.DiagnosticEvents 1.0 GitHub.VisualStudio 2.6.0.6193 IncrediBuild Build Acceleration 1.5.0.3 JavaScript Language Service 2.0 JavaScript Project System 2.0 JavaScript UWP Project System 2.0 JetBrains ReSharper Ultimate 2018.3.4 Build 183.0.20190304.43214 Microsoft Azure HDInsight Azure Node 2.3.8000.0 Microsoft Azure Hive Query Language Service 2.3.8000.0 Microsoft Azure Service Fabric Tools for Visual Studio 2.4 Microsoft Azure Stream Analytics Language Service 2.3.8000.0 Microsoft Azure Stream Analytics Node 1.0 Microsoft Azure Tools 2.9 Microsoft Continuous Delivery Tools for Visual Studio 0.4 Microsoft JVM Debugger 1.0 Microsoft Library Manager 1.0 Microsoft MI-Based Debugger 1.0 Microsoft Visual C++ Wizards 1.0 Microsoft Visual Studio Tools for Containers 1.1 Microsoft Visual Studio VC Package 1.0 MLGen Package Extension 1.0 Mono Debugging for Visual Studio 4.13.12-pre (9bc9548) Node.js Tools 1.4.21001.1 Commit Hash:8dd15923800d931b153ab9e4de74e42a74eba5e6 NuGet Package Manager 4.6.0 Office Developer Tools for Visual Studio 2017 ENU 15.0.28224.00 ProjectServicesPackage Extension 1.0 Python 15.9.18254.1 Python - Django support 15.9.18254.1 Python - IronPython support 15.9.18254.1 Python - Profiling support 15.9.18254.1 Python - UWP support 15.9.18254.1 Python - VC Project Support 15.8.18116.3 R Tools for Visual Studio 1.3.40517.1016 Redgate SQL Prompt 9.4.15.8960 ResourcePackage Extension 1.0 ResourcePackage Extension 1.0 SQL Server Data Tools 15.1.61903.01040 Syntax Visualizer 1.0 Test Adapter for Boost.Test 1.0 Test Adapter for Google Test 1.0 ToolWindowHostedEditor 1.0 TypeScript Tools 15.9.20918.2001 Visual Basic Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a Visual C++ for Cross Platform Mobile Development (Android) 15.0.28107.00 Visual C++ for Linux Development 1.0.9.28218 Visual F# Tools 10.2 for F# 4.5 15.8.0.0. Commit Hash: 6e26c5bacc8c4201e962f5bdde0a177f82f88691. Visual Studio Code Debug Adapter Host Package 1.0 Visual Studio Tools for Apache Cordova 15.123.7408.1 Visual Studio Tools for CMake 1.0 Visual Studio Tools for Containers 1.0 Visual Studio Tools for Unity 3.9.0.3 Visual Studio Tools for Universal Windows Apps 15.0.28307.556 VisualStudio.Mac 1.0 Workflow Manager Tools 1.0 1.0 Xamarin 4.12.3.81 (d15-9@780082716) Xamarin Designer 4.16.13 (45a16efd4) Xamarin Templates 1.1.128 (6f5ebb2) Xamarin.Android SDK 9.1.7.0 (HEAD/ba9da7a76) Xamarin.iOS and Xamarin.Mac SDK 12.2.1.16 (2dc06c7) |
@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 |
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 I'm on 15.9.10 now. |
If I comment out that PackageReference in your repro, I get the following error:
|
Thanks. That is what I saw before, and am not seeing now. I might just need an eye doctor appointment... 👓 |
This issues can be closed? |
@cfguimaraes Agreed, on .NET SDK 2.2, if I change my reference from Similarly, if I then add
(@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"!) |
…build 20191002.2 (dotnet#3046) - Microsoft.NET.Sdk.Razor - 3.1.0-preview1.19502.2
Uh oh!
There was an error while loading. Please reload this page.
This issue is effectively the same issue @natemcmaster has reported in dotnet/AspNetCore.Docs#9490 (comment) for .NET Core 2.2 -> 3.0 migrations, but the regression goes back to at least 2.1 -> 2.2 upgrades as well:
Consider the following project structure:
and the following definitions for
WebApi.csproj
andWebApi.Tests.csproj
:WebApi.csproj
WebApi.Tests.csproj
If you build the solution,
Tests\WebApi.Tests\obj\project.assets.json
will show references to Microsoft.AspNetCore.All metapackage for .NET Core 2.1The only solution is to use
AllowExplicitVersion="true"
:The error message is:
The text was updated successfully, but these errors were encountered: