Msbuild: Cannot find reference assemblies for .NET 3.5 using .NET 5.0 SDK

Created on 21 Dec 2020  ยท  5Comments  ยท  Source: dotnet/msbuild

Issue Description

Failed to build .NET Framework 3.5 targeted class library using .NET 5.0 SDK.

Steps to Reproduce

git clone https://github.com/ganeshnj/DotNet5ReferenceAssemblies
cd DotNet5ReferenceAssemblies
dotnet build

Output

C:\Program Files\dotnet\sdk\5.0.101\Microsoft.Common.CurrentVersion.targets(1180,5): error MSB3644: The reference assemblies for .NETFramework,Version=v3.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [C:\source\repos\DotNet5ReferenceAssemblies\DotNet5ReferenceAssemblies.csproj]

Expected Behavior

This issues existed previously also which was mitigated using this workaround.

Actual Behavior

dotnet build should build the project.

Analysis

I suspect .NET 5 CLI introduces some breaking changes that causes this behavior. If I force 3.1 version of .NET Core SDK, build succeeds.

Branch fix-35-reference-assemblies

global.json

{
  "sdk": {
    "version": "3.1.101",
    "rollForward": "latestFeature"
  }
}

Versions & Configurations

โฏ dotnet --list-sdks
3.1.301 [C:\Program Files\dotnet\sdk]
5.0.101 [C:\Program Files\dotnet\sdk]
โฏ [System.Environment]::OSVersion
Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.18363.0 Microsoft Windows NT 10.0.18363.0

Attach a binlog

msbuild.zip

bug untriaged

Most helpful comment

I've found workaroud

set properties
```` msbuild
$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework.NETFramework\v3.5\Profile\Client
false

````

All 5 comments

VS uses msbuild for building and it's works as expected
Rider also have errors on build SDK-style projects with net35 targets

I've found deferent behaviors:

failed build:
image

success build:
image

I've found workaroud

set properties
```` msbuild
$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework.NETFramework\v3.5\Profile\Client
false

````

It looks like that means $(MSBuildFrameworkToolsRoot) was evaluated to ''. That's normally set in Microsoft.NetFramework.CurrentVersion.props, but that wasn't imported because exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.NETFramework.props\ImportBefore') (C:\Users\jangirg\AppData\Local\Microsoft\MSBuild\Current\Microsoft.NETFramework.props\ImportBefore) evaluated to false. Not sure if that's supposed to exist or if one of those properties is set to the wrong value.

@Forgind Try to get a repro going. See what happens if we target netcoreapp3.1

Was this page helpful?
0 / 5 - 0 ratings