【问题标题】:ASP.NET Core 1.0.0 Nuget Dependency issueASP.NET Core 1.0.0 Nuget 依赖问题
【发布时间】:2016-07-09 07:07:45
【问题描述】:

使用 Visual Studio 2015 Update 3,我创建了一个新的 ASP.NET Core 项目(首先是数据库)。对于客户端,我需要很多 javascript 库,如 angular、ui-select、select2、breadcrumb、metismenu、gritter 等。我知道其中一些是使用 Bower 包管理器包含的,但有些只能使用 NuGet 包管理器找到。 NuGet 也有更新版本的包。 因此,我安装了使用 Bower 能够找到的内容,然后使用 NuGet 添加了其余内容。安装后这里是文件夹结构:

在 Dependency 文件夹下,您可以看到 Bower 的子文件夹,但 Nuget 没有。 我可以在 wwwroot/lib 文件夹中看到使用 Bower 安装的 javascript 库,但我不知道通过 NuGet 安装的库在哪里。我知道在以前版本的 ASP 中,客户端的 NuGet 包安装在“内容”和“脚本”文件夹中,但由于 ASP.Net 添加了“wwwroot”文件夹,它们应该放在此处。 Bellow 是我的 project.json 文件:

{
  "userSecretsId": "aspnet-CipoCloud-7dc0416a-50c0-486e-8b0d-dbe26539c996",

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
    "Microsoft.EntityFrameworkCore.SqlServer.Design": {
      "version": "1.0.0",
      "type": "build"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Angular.UI.UI-Router": "0.2.18",
    "AngularJS.Sanitize": "1.5.7",
    "jQuery.Gritter": "1.7.4",
    "Newtonsoft.Json": "9.0.1",
    "metisMenu": "2.4.0",
    "ncuillery.angular-breadcrumb": "0.4.1"
  },

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

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

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

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

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

  "scripts": {
    "prepublish": \[ "bower install", "dotnet bundle" \],
    "postpublish": \[ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" \]
  }
}

如何在 ASP.NET Core 中引用通过 NuGet 安装的客户端库?我应该使用什么路径?

【问题讨论】:

  • 我在 project.lock.json 文件中找到,该部分描述了应该由 Nuget Ex 安装的库的路径:“libraries”:{“Angular.UI.UI-Router/0.2. 18”:{“sha512”:“...”,“类型”:“包”,“路径”:“Angular.UI.UI-Router/0.2.18”,“文件”:[“Angular.UI. UI-Router.0.2.18.nupkg.sha512”、“Angular.UI.UI-Router.nuspec”、“content/scripts/angular-ui-router.js”、“content/scripts/angular-ui-router. min.js" ] },但项目中缺少文件。
  • 有人知道这个吗?我面临同样的问题,到目前为止所有答案都说“使用 NPM”,但这似乎并没有回答根本问题......

标签: c# asp.net-core visual-studio-2015 nuget


【解决方案1】:

请查看References --> .NETCoreApp,Version=v1.0

【讨论】:

  • @BalaSakthis 没有什么重要的。我可以看到已安装软件包的列表,甚至它们的位置,但该路径不适用于项目。我需要一条与我的项目相关的路径。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-20
  • 1970-01-01
  • 1970-01-01
  • 2020-02-18
相关资源
最近更新 更多