Standard: Problem upgrading NETStandard.Library from 2.0.1 to 2.0.3

Created on 20 Jun 2018  Â·  16Comments  Â·  Source: dotnet/standard

  • ASP.NET MVC project
  • Using NuGet, I see there is a new version of NETStandardLibrary so I elect to upgrade it
  • After upgrading to 2.0.3, I can no longer build the solution. I get this error:
    This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information (blah, blah, blah)… The missing file is ..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets

The only way to proceed is to revert back to 2.0.1.

Most helpful comment

In that case it looks like NuGet didn't delete the old imports from the project file.

You can delete

 <Error Condition="!Exists('..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets'))" />

And

  <Import Project="..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets')" />

And that should fix your project.

It does appear to be a NuGet bug. The fact that Nuget wrote imports for both build\NETStandard.Library.targets and build\netstandard2.0\NETStandard.Library.targets is likely a bug. I couldn't reproduce that in the version of NuGet I was using. @rrelyea does this sound familiar to you?

@pmarangoni can you reproduce the two imports for NETStandard.Library.targets? If you can catch NuGet writing these we can file the issue on NuGet. If not, its possible that some previous version of NuGet had a bug and the new version has a fix that doesn't clean up for the old bug.

All 16 comments

have you installed .Net Core 2.1 SDK (2.1.300)?

This is a fully up-to-date Visual Studio Community 2017. I have built ASP.NET Core web apps with it as well.

Nothing should be referencing packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets if you've updated to 2.0.3. Your project file is in a state where NuGet isn't cleaning up the state of the old package.

It could be that the packages.config file was saved but the CSProj was not, or that NuGet couldn't locate the import statement that it previously wrote for 2.0.1.

If you can share your CSProj (if you want you can omit any of your content, I'm just interested in the imports and targets) and packages.config I can help you repair it.

If you can consistently reproduce this "orphaned import" behavior we can file a bug on nuget.

From the csproj:

<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets'))" />
    <Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.8.2\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.8.2\build\Microsoft.Net.Compilers.props'))" />
    <Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
    <Error Condition="!Exists('..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets'))" />
  </Target>
  <Import Project="..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets')" />
  <Import Project="..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.1\build\netstandard2.0\NETStandard.Library.targets')" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target> -->

packages.config:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Antlr" version="3.5.0.2" targetFramework="net461" />
  <package id="Aspose.Words" version="18.6.0" targetFramework="net47" />
  <package id="AuthorizeNet" version="1.9.4" targetFramework="net47" />
  <package id="bootstrap" version="3.3.7" targetFramework="net461" />
  <package id="ckeditor-full" version="4.9.2" targetFramework="net47" />
  <package id="EntityFramework" version="6.2.0" targetFramework="net47" />
  <package id="FontAwesome" version="4.7.0" targetFramework="net461" />
  <package id="FontAwesome.MVC" version="1.0.0" targetFramework="net461" />
  <package id="jQuery" version="3.3.1" targetFramework="net47" />
  <package id="jQuery.InputMask" version="4.0.0" targetFramework="net47" />
  <package id="jQuery.UI.Combined" version="1.12.1" targetFramework="net461" />
  <package id="jQuery.Validation" version="1.17.0" targetFramework="net47" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net461" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net461" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net461" />
  <package id="Microsoft.AspNet.Mvc" version="5.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.Razor" version="3.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.6" targetFramework="net47" />
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net47" />
  <package id="Microsoft.jQuery.Unobtrusive.Ajax" version="3.2.5" targetFramework="net47" />
  <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.10" targetFramework="net47" />
  <package id="Microsoft.Net.Compilers" version="2.8.2" targetFramework="net47" developmentDependency="true" />
  <package id="Microsoft.NETCore.Platforms" version="2.1.0" targetFramework="net47" />
  <package id="Microsoft.Owin" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.Cookies" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.Facebook" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.Google" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.MicrosoftAccount" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.OAuth" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.Twitter" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
  <package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net47" />
  <package id="Modernizr" version="2.8.3" targetFramework="net461" />
  <package id="NETStandard.Library" version="2.0.1" targetFramework="net47" />
  <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net47" />
  <package id="Owin" version="1.0" targetFramework="net461" />
  <package id="PayPal" version="1.9.1" targetFramework="net47" />
  <package id="Respond" version="1.4.2" targetFramework="net461" />
  <package id="Spin.js" version="2.3.2.1" targetFramework="net461" />
  <package id="System.AppContext" version="4.3.0" targetFramework="net47" />
  <package id="System.Collections" version="4.3.0" targetFramework="net47" />
  <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net47" />
  <package id="System.Console" version="4.3.1" targetFramework="net47" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net47" />
  <package id="System.Diagnostics.DiagnosticSource" version="4.5.0" targetFramework="net47" />
  <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net47" />
  <package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net47" />
  <package id="System.Globalization" version="4.3.0" targetFramework="net47" />
  <package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net47" />
  <package id="System.IO" version="4.3.0" targetFramework="net47" />
  <package id="System.IO.Compression" version="4.3.0" targetFramework="net47" />
  <package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net47" />
  <package id="System.IO.FileSystem" version="4.3.0" targetFramework="net47" />
  <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net47" />
  <package id="System.Linq" version="4.3.0" targetFramework="net47" />
  <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net47" />
  <package id="System.Linq.Queryable" version="4.3.0" targetFramework="net461" />
  <package id="System.Net.Http" version="4.3.3" targetFramework="net47" />
  <package id="System.Net.Primitives" version="4.3.0" targetFramework="net47" />
  <package id="System.Net.Sockets" version="4.3.0" targetFramework="net47" />
  <package id="System.ObjectModel" version="4.3.0" targetFramework="net47" />
  <package id="System.Reflection" version="4.3.0" targetFramework="net47" />
  <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net47" />
  <package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net47" />
  <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime.Handles" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net47" />
  <package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net47" />
  <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net47" />
  <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net47" />
  <package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="net47" />
  <package id="System.Text.Encoding" version="4.3.0" targetFramework="net47" />
  <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net47" />
  <package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net47" />
  <package id="System.Threading" version="4.3.0" targetFramework="net47" />
  <package id="System.Threading.Tasks" version="4.3.0" targetFramework="net47" />
  <package id="System.Threading.Timer" version="4.3.0" targetFramework="net47" />
  <package id="System.Xml.ReaderWriter" version="4.3.1" targetFramework="net47" />
  <package id="System.Xml.XDocument" version="4.3.0" targetFramework="net47" />
  <package id="WebActivatorEx" version="2.2.0" targetFramework="net461" />
  <package id="WebGrease" version="1.6.0" targetFramework="net461" />
  <package id="X.PagedList" version="7.5.0" targetFramework="net47" />
  <package id="X.PagedList.Mvc" version="7.5.0" targetFramework="net47" />
</packages>

Both of these are currently in the state where you are have only installed NETStandard.Library 2.01. Can you update to NETStandard.Library 2.0.3 and share them?

CSProj:

  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets'))" />
    <Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.8.2\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.8.2\build\Microsoft.Net.Compilers.props'))" />
    <Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.0\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
    <Error Condition="!Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets'))" />
  </Target>
  <Import Project="..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets')" />
  <Import Project="..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Antlr" version="3.5.0.2" targetFramework="net461" />
  <package id="Aspose.Words" version="18.6.0" targetFramework="net47" />
  <package id="AuthorizeNet" version="1.9.5" targetFramework="net47" />
  <package id="bootstrap" version="3.3.7" targetFramework="net461" />
  <package id="ckeditor-full" version="4.9.2" targetFramework="net47" />
  <package id="EntityFramework" version="6.2.0" targetFramework="net47" />
  <package id="FontAwesome" version="4.7.0" targetFramework="net461" />
  <package id="FontAwesome.MVC" version="1.0.0" targetFramework="net461" />
  <package id="jQuery" version="3.3.1" targetFramework="net47" />
  <package id="jQuery.InputMask" version="4.0.0" targetFramework="net47" />
  <package id="jQuery.UI.Combined" version="1.12.1" targetFramework="net461" />
  <package id="jQuery.Validation" version="1.17.0" targetFramework="net47" />
  <package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net461" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net461" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net461" />
  <package id="Microsoft.AspNet.Mvc" version="5.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.Razor" version="3.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net461" />
  <package id="Microsoft.AspNet.WebApi" version="5.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.WebApi.Client" version="5.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.6" targetFramework="net47" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.6" targetFramework="net47" />
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="2.0.0" targetFramework="net47" />
  <package id="Microsoft.jQuery.Unobtrusive.Ajax" version="3.2.5" targetFramework="net47" />
  <package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.10" targetFramework="net47" />
  <package id="Microsoft.Net.Compilers" version="2.8.2" targetFramework="net47" developmentDependency="true" />
  <package id="Microsoft.NETCore.Platforms" version="2.1.0" targetFramework="net47" />
  <package id="Microsoft.Owin" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Host.SystemWeb" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.Cookies" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.Facebook" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.Google" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.MicrosoftAccount" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.OAuth" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Owin.Security.Twitter" version="4.0.0" targetFramework="net47" />
  <package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
  <package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net47" />
  <package id="Modernizr" version="2.8.3" targetFramework="net461" />
  <package id="NETStandard.Library" version="2.0.3" targetFramework="net47" />
  <package id="Newtonsoft.Json" version="11.0.2" targetFramework="net47" />
  <package id="Owin" version="1.0" targetFramework="net461" />
  <package id="PayPal" version="1.9.1" targetFramework="net47" />
  <package id="Respond" version="1.4.2" targetFramework="net461" />
  <package id="Spin.js" version="2.3.2.1" targetFramework="net461" />
  <package id="System.AppContext" version="4.3.0" targetFramework="net47" />
  <package id="System.Collections" version="4.3.0" targetFramework="net47" />
  <package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net47" />
  <package id="System.Console" version="4.3.1" targetFramework="net47" />
  <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net47" />
  <package id="System.Diagnostics.DiagnosticSource" version="4.5.0" targetFramework="net47" />
  <package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net47" />
  <package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net47" />
  <package id="System.Globalization" version="4.3.0" targetFramework="net47" />
  <package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net47" />
  <package id="System.IO" version="4.3.0" targetFramework="net47" />
  <package id="System.IO.Compression" version="4.3.0" targetFramework="net47" />
  <package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net47" />
  <package id="System.IO.FileSystem" version="4.3.0" targetFramework="net47" />
  <package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net47" />
  <package id="System.Linq" version="4.3.0" targetFramework="net47" />
  <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net47" />
  <package id="System.Linq.Queryable" version="4.3.0" targetFramework="net461" />
  <package id="System.Net.Http" version="4.3.3" targetFramework="net47" />
  <package id="System.Net.Primitives" version="4.3.0" targetFramework="net47" />
  <package id="System.Net.Sockets" version="4.3.0" targetFramework="net47" />
  <package id="System.ObjectModel" version="4.3.0" targetFramework="net47" />
  <package id="System.Reflection" version="4.3.0" targetFramework="net47" />
  <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net47" />
  <package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net47" />
  <package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime.Handles" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net47" />
  <package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net47" />
  <package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net47" />
  <package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net47" />
  <package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net47" />
  <package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="net47" />
  <package id="System.Text.Encoding" version="4.3.0" targetFramework="net47" />
  <package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net47" />
  <package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="net47" />
  <package id="System.Threading" version="4.3.0" targetFramework="net47" />
  <package id="System.Threading.Tasks" version="4.3.0" targetFramework="net47" />
  <package id="System.Threading.Timer" version="4.3.0" targetFramework="net47" />
  <package id="System.Xml.ReaderWriter" version="4.3.1" targetFramework="net47" />
  <package id="System.Xml.XDocument" version="4.3.0" targetFramework="net47" />
  <package id="WebActivatorEx" version="2.2.0" targetFramework="net461" />
  <package id="WebGrease" version="1.6.0" targetFramework="net461" />
  <package id="X.PagedList" version="7.5.0" targetFramework="net47" />
  <package id="X.PagedList.Mvc" version="7.5.0" targetFramework="net47" />
</packages>`

In that case it looks like NuGet didn't delete the old imports from the project file.

You can delete

 <Error Condition="!Exists('..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets'))" />

And

  <Import Project="..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets')" />

And that should fix your project.

It does appear to be a NuGet bug. The fact that Nuget wrote imports for both build\NETStandard.Library.targets and build\netstandard2.0\NETStandard.Library.targets is likely a bug. I couldn't reproduce that in the version of NuGet I was using. @rrelyea does this sound familiar to you?

@pmarangoni can you reproduce the two imports for NETStandard.Library.targets? If you can catch NuGet writing these we can file the issue on NuGet. If not, its possible that some previous version of NuGet had a bug and the new version has a fix that doesn't clean up for the old bug.

How do you suggest I try to reproduce the two imports? I'm not sure what you're asking.

On my machine I tried a new desktop app and installed NETStandard 2.0.1 and then upgraded to 2.0.3, using VS 2017. I didn't reproduce the two imports with 2.0.1 and thus didn't have the issue on upgrade.

It's possible that you can still reproduce the two-imports state by doing something similar to whatever you did to your own project and we can share those steps with NuGet and file an issue. Variables that may be different for you: VS version, NuGet version, type of project, project references, etc etc. Something here could be resulting in the bad project state.

If you can't get a new repro than we'll just chalk it up to a bug in a previous version of NuGet and we'll move on after applying the workaround.

Oh, got it. Good idea. I will try doing just that later today or tomorrow and report back.

I was unable to recreate the issue. Before applying your fix of modifying the CSProj file, I first tried to completely remove NetStandard from the solution with NuGet, and I still got the same error. I then applied your fix to delete those lines from the CSProj file and everything is fine now. I have no idea when or how things got our of sync like that.

Thank you for your help Eric.

In that case it looks like NuGet didn't delete the old imports from the project file.

You can delete

 <Error Condition="!Exists('..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets'))" />

And

  <Import Project="..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.1\build\NETStandard.Library.targets')" />

And that should fix your project.

It does appear to be a NuGet bug. The fact that Nuget wrote imports for both build\NETStandard.Library.targets _and_ build\netstandard2.0\NETStandard.Library.targets is likely a bug. I couldn't reproduce that in the version of NuGet I was using. @rrelyea does this sound familiar to you?

@pmarangoni can you reproduce the two imports for NETStandard.Library.targets? If you can catch NuGet writing these we can file the issue on NuGet. If not, its possible that some previous version of NuGet had a bug and the new version has a fix that doesn't clean up for the old bug.

Removing the 2 lines fixed it for me.

My solution includes a .NET Standard shared library that implicitly references NETStandard.Library (2.0.3). Since it's implicitly referenced, there is no need for explicit reference in packages folder. Therefore Nuget was not restoring it, and the following lines in my main web forms project's csproj were causing a build error.
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> <PropertyGroup> <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> </PropertyGroup> <Error Condition="!Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets'))" /> </Target> <Import Project="..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
For the, the fix was simply to manually edit and remove those lines.

I hit this as well, and the fix was the same: manual edit of the lines that were not cleaned up.

Was this page helpful?
0 / 5 - 0 ratings