-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
dotnet build for .net 4.7 library fails citing missing references #8931
Comments
Can you share a small repro with us or your project files? cc @dsplaisted |
Yes I was surprised it's pretty easy to replicate. Sample code attached below.
|
The dotnet cli does not support old style csproj files and does not support windows desktop projects, which is why it fails for you. |
That sucks. I got to this point because I created a new ASP.Net Core 2 web app but I have existing class libraries that use System.Drawing functionality and therefore I still need to target the full framework. Everything seems to work fine in VS except when I go to publish the app to Azure it doesn't find any DbContexts so Enable migrations checkbox is not shown. When I try to use the ef CLI to list the dbcontext it fails I followed the chain down I see the Build fails on the class libraries. So the issue in the UI is probably related to the mix of frameworks. I guess I might have to try out 'System.Drawing for .NET Core 2.0' compatibility package and see if I can convert the class libraries. It just sends a very confusing message when most of this is supported in the VS but not in the CL. |
Unfortunately, not all the tooling that is available in VS is available in the CLI. There are many things in VS that are windows only and we try to maintain the CLI as portable across OSes as possible, but also, VS is simply ahead of the CLI in time. I would recommend using msbuild.exe in the command line if you want to have a command line experience that can work with your projects. This works in MSBuild (likely) because that is the msbuild that comes with VS and as such has all the props/targets that implement this extra functionality on the VS side. |
My final thought on this matter. So I spent about a day converting over my class libraries to .net core (hacking and commenting around some System.Drawing issues) and got everything working. DbContexts and enable migrations checkbox now appears in the Web Publish settings so obviously that code was using the EF tools which were failing on the build. I did notice in the CLI there are warnings for packages that don't have core versions but not build failures. I've attached a small sample project and dotnet output below. It seems to me that dotnet build could do the same whether the class library is targeting .net core or full framework.
|
@bradleypatton I am sorry, I don't follow your suggestion. What would you expect dotnet build to do? |
My suggestion or hope would be if dotnet could issue warnings rather than fail to build if it encounters framework assemblies (even if there are runtime errors later). The reason this is a big issue is that Visual Studio seems to support mixing full framework and .core packages. But then some functionality in VS breaks because under the covers it is calling dotnet and the cmdline is failing. I'm in the process of trying to convert all of my code to .net core projects because I just don't see the mixed code working very well. |
Not sure if anyone is still facing this issue without a solution. After some experiments I found out that the issue is with dotnet cli's having trouble restoring the nuget packages and referencing them properly for the old style projects. I have 2 solutions for this:
|
Steps to reproduce
I have a ASP.Net Core 2 web application with class libraries that target the .net 4.7 framework. Visual Studio compiles fine but dotnet build fails. I've tracked the errors down to the class libraries which I've switched to use. I've followed the workarounds here (dotnet/standard#481) and switched the library to use PackageReferences in the .csproj file and remove the packages.config. After some initial issues VS compiles fine and nuget restore works without issue but dotnet build still fails.
Expected behavior
dotnet build succeeds.
Actual behavior
Multiple errors about missing assemblies (ie Nuget Package references).
ApplicationSupport\EmailConfiguration.cs(4,7): error CS0246: The type or namespace name 'Newtonsoft' could not be found (are you missing a using directive or an assembly reference?) [C:\Dev\Neptune\Neptune.Common\Neptune.Common.csproj]
Environment data
dotnet --info
output:.NET Command Line Tools (2.1.2)
Product Information:
Version: 2.1.2
Commit SHA-1 hash: 5695315
Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.2\
Microsoft .NET Core Shared Framework Host
Version : 2.0.3
Build : a9190d4a75f4a982ae4b4fa8d1a24526566c69df
The text was updated successfully, but these errors were encountered: