sdk icon indicating copy to clipboard operation
sdk copied to clipboard

DOTNET1011 when building/running net451 project on a machine with NET 4.6.1 only installed

Open moozzyk opened this issue 10 years ago • 8 comments

Steps to reproduce

Create/Clone a project targeting net451 on a machine that has only .NET 4.6.1 installed (including dev pack) dotnet build/run fails with:

error DOTNET1011: Framework not installed: .NETFramework,Version=v4.5.1 in...

Expected behavior

Since .NET Frameworks are in place updates these days and APIs are backwards compatible I would expect the project to build fine if I have all the required bits (i.e. runtime and ref assemblies) of a newer version of .NET that the one that the app is targetting.

Actual behavior

error DOTNET1011: Framework not installed: .NETFramework,Version=v4.5.1 in...

Environment data

dotnet --info output:

PS C:\Users\XXXX\source\cli-samples\HelloMvc> dotnet --info
.NET Command Line Tools (1.0.0-preview2-003118)

Product Information:
 Version:            1.0.0-preview2-003118
 Commit SHA-1 hash:  7ada53d523

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x86

moozzyk avatar Jun 21 '16 23:06 moozzyk

I would expect the "not installed" to be coming because the reference assemblies don't exist for .NET 4.5.1 which I suspect would be true. While we are depending on the reference assemblies it is probably a good idea to improve the error message and at least point to where to install them from. However ideally we would just have packages for the different target framework reference assemblies that will work.

I personally wouldn't expect it to work if you are targeting net451 and only have net46 on the box because you would then not be able to take your output and run it on a machine that only has net451.

weshaggard avatar Jun 21 '16 23:06 weshaggard

@weshaggard - can you elaborate on this:

I personally wouldn't expect it to work if you are targeting net451 and only have net46 on the box because you would then not be able to take your output and run it on a machine that only has net451.

I am assuming this is a legit net451 project is not using APIs that were not available on net46.

The main motivation for filing this bug is the scenario where you clone a project and the project is targeting an older version of .NET Framework that you have on the box. Now you need to install ref assemblies to be able to do anything in the project (including actions for other targets - https://github.com/dotnet/cli/issues/3658) or modify the project to target a newer version of .NET (which may be rejected if you don't own the project).

moozzyk avatar Jun 22 '16 00:06 moozzyk

I completely agree the experience needs to be improved around building projects targeting .NET Framework. Issue https://github.com/dotnet/cli/issues/191 is already tracking at least some of that work.

I am assuming this is a legit net451 project is not using APIs that were not available on net46.

It is legit to run a project targeting net451 on a machine with net46 but there isn't any way to target net451 on a machine that doesn't have a set of reference assemblies that represent the net451 API surface. In general it is not supported to build against net46 and run on net451. You can sometimes get lucky if you know how to restrict what you are using but it isn't always in your control. For example we added Array.Empty in net46 and the compiler will use that in codegen if it sees it available in the references you are providing, and so if you end up with that reference you will fail to run on net451.

weshaggard avatar Jun 22 '16 15:06 weshaggard

Thanks for your explanation. This is the bit I was not sure about:

and the compiler will use that in codegen if it sees it available

With that I agree that you can't float to a newer version of .NET Framework reference assemblies automatically.

I will leave this issue open just in case you think it is useful to track the user experience issues. If you don't think it's useful because you track it in the other issue feel free to close.

moozzyk avatar Jun 22 '16 16:06 moozzyk

I will let @blackdwarf @cartermp decide what to do with this issue as they are they should be the ones driving this experience.

weshaggard avatar Jun 22 '16 17:06 weshaggard

Self-assigning this because of the error. It needs to be better.

thesmithee avatar Jun 22 '16 18:06 thesmithee

Actrually, since we are moving to MSBuild now, the error on build is much cleaner and specified very clearly that reference assemblies are missing and that they should be installed. With that, I will close this issue. If this resurfaces or additional info is needed, please reopen.

thesmithee avatar Dec 20 '16 01:12 thesmithee

"specified very clearly that reference assemblies are missing" Does it specify very clearly exactly which reference assemblies are missing.

I have been fighting with this issue for most of this morning and cannot figure out exactly which of the innumerable versions is missing

Mattacks avatar Jan 13 '17 11:01 Mattacks