sdk: .Net Core 2.0 SDK causes ASP.Net 1.1 Web App with project references to break

After I installed the .Net Core 2.0 SDK I started getting an InvalidOperationException: Can not find assembly file Microsoft.CSharp.dll at 'C:\Projects\Temp\VS2017Issue\WebApplication1\bin\Debug\net462\refs,C:\Projects\Temp\VS2017Issue\WebApplication1\bin\Debug\net462\ error at runtime on a web application that references a class library project.

If I remove the class library project reference then the runtime error goes away.

Falling back to the .Net Core 1.0.4 SDK (uninstall 2.0 or use global.json to target 1.0.4) also fixes the issue.

I have a sample app that reproduces the issue at https://github.com/squareitechnologies/VS2017Issue

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 10
  • Comments: 26 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I believe this may be an issue of new logic to generate the deps.json file requiring a new version of Microsoft.Extension.DependencyModel that include https://github.com/dotnet/core-setup/commit/35749847a0fa555e2c758da17f52b6eaef2164be (or some other change).

Adding a reference to the new NuGet package for the ASP.NET Core 1.1 app resolves the issue in @jeffpapp’s example project on my machine:

<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.0.0" />

cc @eerhardt

I managed my project to build with SDK 1.0.4 after commenting this out in file Microsoft.NET.Build.Extensions.NETFrameworks.targets

<!-- prevent using an older SDK version with NETStandard2.0 references --><!--
    <PropertyGroup>
      <_UsingOldSDK Condition="'$(UsingMicrosoftNETSdk)' != 'true' AND ('$(TargetFramework)' != '' OR '$(TargetFrameworks)' != '')">true</_UsingOldSDK>
    </PropertyGroup>
    <NETBuildExtensionsError Condition="'$(DependsOnNETStandard)' == 'true' AND '$(NETStandardInbox)' != 'true' AND '$(_UsingOldSDK)' == 'true'" ResourceName="UnsupportedSDKVersionForNetStandard20"/>-->

although I do not think it is a smart move.

UPDATE: Silly me, I just added <DependsOnNETStandard>netstandard1.6</DependsOnNETStandard> as @TomGroeneboer wrote. Works perfect for me.