Closed jnevins-gcm closed 3 years ago
Could you post the exact output you're seeing? Under the hood, we generate a project file containing the package you've indicated, call dotnet restore
on it (passing a location to restore the packages to) and then scan the packages it's restored for templates or components.
dotnet restore
has several different behaviors for package constraint mismatches, knowing which one & what messages you've gotten will help narrow down whether there's something we can do or if we need to ask the NuGet team to change something in restore.
Sure - pretty easy to reproduce
C:\Dev>dotnet new -i "My.Template::0.1.2345" && echo succeeded anyway
Restoring packages for C:\Users\user\.templateengine\dotnetcli\v2.1.403\scratch\restore.csproj...
C:\Users\user\.templateengine\dotnetcli\v2.1.403\scratch\restore.csproj : error NU1101: Unable to find package My.Template. No packages exist with this id in source(s): C:\Program Files\dotnet\sdk\NuGetFallbackFolder, DevOps, Microsoft Visual Studio Offline Packages
Generating MSBuild file C:\Users\user\.templateengine\dotnetcli\v2.1.403\scratch\obj\restore.csproj.nuget.g.props.
Generating MSBuild file C:\Users\user\.templateengine\dotnetcli\v2.1.403\scratch\obj\restore.csproj.nuget.g.targets.
Restore failed in 1.48 sec for C:\Users\user\.templateengine\dotnetcli\v2.1.403\scratch\restore.csproj.
Usage: new [options]
Options:
-h, --help Displays help for this command.
-l, --list Lists templates containing the specified name. If no name is specified, lists all templates.
-n, --name The name for the output being created. If no name is specified, the name of the current directory is used.
-o, --output Location to place the generated output.
-i, --install Installs a source or a template pack.
-u, --uninstall Uninstalls a source or a template pack.
--nuget-source Specifies a NuGet source to use during install.
--type Filters templates based on available types. Predefined values are "project", "item" or "other".
--force Forces content to be generated even if it would change existing files.
-lang, --language Filters templates based on language and specifies the language of the template to create.
Templates Short Name Language Tags
------------------------------------------------------------------------------------------------------------------------------
Console Application console [C#], F#, VB Common/Console
Class library classlib [C#], F#, VB Common/Library
Unit Test Project mstest [C#], F#, VB Test/MSTest
NUnit 3 Test Project nunit [C#], F#, VB Test/NUnit
NUnit 3 Test Item nunit-test [C#], F#, VB Test/NUnit
xUnit Test Project xunit [C#], F#, VB Test/xUnit
Razor Page page [C#] Web/ASP.NET
MVC ViewImports viewimports [C#] Web/ASP.NET
MVC ViewStart viewstart [C#] Web/ASP.NET
ASP.NET Core Empty web [C#], F# Web/Empty
ASP.NET Core Web App (Model-View-Controller) mvc [C#], F# Web/MVC
ASP.NET Core Web App razor [C#] Web/MVC/Razor Pages
ASP.NET Core with Angular angular [C#] Web/MVC/SPA
ASP.NET Core with React.js react [C#] Web/MVC/SPA
ASP.NET Core with React.js and Redux reactredux [C#] Web/MVC/SPA
Razor Class Library razorclasslib [C#] Web/Razor/Library/Razor Class Library
ASP.NET Core Web API webapi [C#], F# Web/WebAPI
global.json file globaljson Config
NuGet Config nugetconfig Config
Web Config webconfig Config
Gcm.MSBuild.Sdk Template Gcm.MSBuild.Sdk Gcm.MSBuild.Sdk
Solution File sln Solution
Examples:
dotnet new mvc --auth Individual
dotnet new angular
dotnet new --help
succeeded anyway
C:\Dev>
The issue will be fixed with https://github.com/dotnet/templating/issues/2745, when implementing that epic install-uninstall was majorly reworked.
The error messages and the result of installation will be now shown to user.
Draft example:
> dotnet new -i Take.Blip.Client.Templates::0.50.10 --nuget-source https://api.nuget.org/v3/index.json
The following template sources will be installed:
Take.Blip.Client.Templates, version: 0.50.10
Warning: Take.Blip.Client.Templates::0.5.10 is not found in NuGet feeds https://api.nuget.org/v3/index.json.
'Take.Blip.Client.Templates::0.50.10' could not be installed, the package does not exist.
Above was implemented and merged to main branch, closing.
When dotnet new -i MyPackage::1.2.3 finds no version match, it logs such to the output, installs and uses an old version it can find (1.2.2 let’s say), and exits with code 0. Further, it seems that nothing is written to stderr
How can I identify a failure? I want to stop, not continue, if dotnet new can’t find a version that meets my spec.