12 votes

L'exécutable dotnet core user-secrets manque mystérieusement, pourquoi ?

J'ai installé le plus récent (je pense) .NET Core, j'ai créé un projet web .NET Core via Visual Studio 2015, et j'ai essayé de commencer à utiliser les secrets d'utilisateur. Le CLI prétend qu'il est manquant (après avoir prétendu l'avoir installé...), comme ci-dessous :

E:\Projects\CodeServer>dotnet --version
1.0.0-preview1-002702

E:\Projects\CodeServer>dotnet restore
 <snip>
log  : Restoring packages for tool 'Microsoft.Extensions.SecretManager.Tools' in E:\Projects\CodeServer\src\CodeServer\project.json...
 <snip>
log  : Restore completed in 2345ms.

NuGet Config files used:
    C:\Users\Work User\AppData\Roaming\NuGet\NuGet.Config
    C:\ProgramData\nuget\Config\Microsoft.VisualStudio.Offline.config

Feeds used:
    https://api.nuget.org/v3/index.json
    C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

E:\Projects\CodeServer>dotnet user-secrets -h
No executable found matching command "dotnet-user-secrets"

E:\Projects\CodeServer>

J'ajoute également le fichier project.json selon la demande :

{
  "userSecretsId": "<snip>",

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-3002702",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc2-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview1-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Authentication.Google": "1.0.0-rc2-final"
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    },
    "Microsoft.Extensions.SecretManager.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

31voto

Daniel Grim Points 2133

Lors de l'utilisation de l'un des paquets d'outils définis dans le fichier tools de votre fichier project.json, vous devez les utiliser à partir du même répertoire qui contient le fichier project.json.

Par exemple, votre fichier project.json se trouve à l'adresse suivante E:\Projects\CodeServer\src\CodeServer\project.json mais vous essayez d'exécuter la commande à partir de E:\Projects\CodeServer . Si vous passez au E:\Projects\CodeServer\src\CodeServer\ avant de tenter d'utiliser les outils, les commandes fonctionneront alors.

12voto

Indregaard Points 146

J'ai constaté que la console du gestionnaire de paquets est parfois (ou tout le temps pour) incapable d'utiliser le bon répertoire (même s'il est sélectionné dans la liste déroulante du projet par défaut). Si vous exécutez d'abord la commande 'cd src \YourProjectName et ensuite, par exemple, 'dotnet user-secrets -h' (pour l'aide), vous devriez être en mesure d'utiliser l'outil user-secrets.

dotnet user-secrets

0voto

La réponse acceptée à cette question est correcte mais le fichier project.JSON n'existe plus. (Visual Studios 2017 et .Net Core 2.1) Il a été remplacé par un fichier "your-app-name".csproj. Référence : il n'y a pas de project.json, global.json ... etc sur une solution .NET Core avec Visual Studio 2017

Prograide.com

Prograide est une communauté de développeurs qui cherche à élargir la connaissance de la programmation au-delà de l'anglais.
Pour cela nous avons les plus grands doutes résolus en français et vous pouvez aussi poser vos propres questions ou résoudre celles des autres.

Powered by:

X