question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Restore hangs when referenced project targets only .net standard 2.0

See original GitHub issue

From @MNie on April 6, 2018 20:53

Steps to reproduce

  1. Try to install an Expecto Template via dotnet new -i Expecto.Template

Expected behavior

  1. Everything is ok, the template is installed as expected.

Actual behavior

$ dotnet new -i Expecto.Template
...
...
~/.templateengine/dotnetcli/v2.1.4/scratch/restore.csproj : error NU1202: Package Expecto 7.0.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package Expecto 7.0.0 supports:
~/.templateengine/dotnetcli/v2.1.4/scratch/restore.csproj : error NU1202:   - net461 (.NETFramework,Version=v4.6.1)
~/.templateengine/dotnetcli/v2.1.4/scratch/restore.csproj : error NU1202:   - netstandard2.0 (.NETStandard,Version=v2.0)
  Generating MSBuild file ~/.templateengine/dotnetcli/v2.1.4/scratch/obj/restore.csproj.nuget.g.props.
  Generating MSBuild file ~/.templateengine/dotnetcli/v2.1.4/scratch/obj/restore.csproj.nuget.g.targets.
  Restore failed in 6.24 sec for ~/.templateengine/dotnetcli/v2.1.4/scratch/restore.csproj.
  1. Installation hangs with an error that Expecto library doesn’t support .net core 1.0 (Expecto supports .net standard 2.0, and drops support to .net standard 1.6 after 7.0 release).
  2. When we cancel the installation, regardless of the error from point 2, a template would be installed properly.

Environment data

dotnet --info output:

.NET Command Line Tools (2.1.103)

Product Information:
 Version:            2.1.103
 Commit SHA-1 hash:  60218cecb5

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.103\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.6
  Build    : 74b1c703813c8910df5b96f304b0f2b78cdf194d

Related issue

Copied from original issue: dotnet/cli#9017

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mlorbetskecommented, Apr 8, 2018

I tried this out and took a look at the template package. The template package’s target framework is OK (not specified). As far as the hang goes, it turns out (at least on Windows, I haven’t tried this on my mac yet) that this isn’t actually a hang. Because of the way that the template is authored (where the libraries used by the template are referenced in the template package itself) the installation process ends up looking through all of the types in all of the DLLs that are restored by the dependencies to see if there are any components that are required for making the template - this process takes a long time (multiple minutes) but does eventually complete, discovering the contained templates and no “components”.

The nupkg containing the template currently has a NuSpec that looks like this:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>Expecto.Template</id>
    <version>8.2.0</version>
    <authors>Michał Niegrzybowski</authors>
    <owners>Michał Niegrzybowski</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <licenseUrl>https://github.com/MNie/Expecto.Template/blob/master/LICENSE</licenseUrl>
    <projectUrl>https://github.com/MNie/Expecto.Template</projectUrl>
    <description>Expecto .net core Template</description>
    <copyright>Copyright 2018</copyright>
    <tags>.net core Expecto template</tags>
    <packageTypes>
      <packageType name="Template" />
    </packageTypes>
    <dependencies>
      <dependency id="Expecto" version="[7.0.0, 8.0.0)" />
      <dependency id="FSharp.Core" version="[4.2.3, 5.0.0)" />
      <dependency id="YoloDev.Expecto.TestSdk" version="[0.5.0, 1.0.0)" />
      <dependency id="Microsoft.NET.Test.Sdk" version="[15.0.0, 16.0.0)" />
    </dependencies>
  </metadata>
</package>

Changing it to this:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
  <metadata>
    <id>Expecto.Template</id>
    <version>8.2.0</version>
    <authors>Michał Niegrzybowski</authors>
    <owners>Michał Niegrzybowski</owners>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <licenseUrl>https://github.com/MNie/Expecto.Template/blob/master/LICENSE</licenseUrl>
    <projectUrl>https://github.com/MNie/Expecto.Template</projectUrl>
    <description>Expecto .net core Template</description>
    <copyright>Copyright 2018</copyright>
    <tags>.net core Expecto template</tags>
    <packageTypes>
      <packageType name="Template" />
    </packageTypes>
  </metadata>
</package>

Should dramatically speed up the installation process (getting it down to a second or so).

0reactions
mlorbetskecommented, Apr 10, 2018

Sounds interesting, I’d suggest filing an issue on NuGet/Home to get their thoughts on it.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Michał Niegrzybowski notifications@github.com Sent: Tuesday, April 10, 2018 3:52:10 AM To: dotnet/templating Cc: Mike Lorbetske; Mention Subject: Re: [dotnet/templating] Restore hangs when referenced project targets only .net standard 2.0 (#1506)

@mlorbetskehttps://github.com/mlorbetske I’m not 100% sure if a description is a right place for something like that. Maybe it would be doable to create some section on NuGet page, which will write all dependencies from some special section in a nuspec if it is a DotNet Core template? Wouldn’t be that a good idea?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/dotnet/templating/issues/1506#issuecomment-380057451, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABWXUeX6Xn-RRnL5s1SsA6cac4AN25Gqks5tnI7agaJpZM4TKxrM.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issues with .NET Standard 2.0 with .NET Framework & NuGet
The project file contains no references to any assets as the assets are selected at build time. Package restore will compute the graph...
Read more >
The current .NET SDK does not support targeting . ...
I want to create a class library project with Target Framework .NET Standard 2.0. I've updated my Visual Studio 2017 to Version 15.3...
Read more >
Troubleshooting NuGet Package Restore in Visual Studio
This error occurs when you attempt to build a project that contains references to one or more NuGet packages, but those packages are...
Read more >
NET Standard
This compatibility mode allows .NET Standard projects to reference .NET Framework libraries as if they were compiled for .NET Standard.
Read more >
Multi-targetting .Net Framework and .Net Core in a single project
A 15-second guide and 15-minute walk through. You have a .Net Core project, whether a netstandard library, or a netcore app, and you'd...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found