asp.net-mvc - 发布 .NET Core 应用程序时出现错误 "Could not find a part of the path"

标签 asp.net-mvc visual-studio-2015 asp.net-mvc-5 asp.net-core publish

我有一个使用 Visual Studio 2015 Update 3 创建的非常简单的 .NET Core Web 应用程序 (.NET Framework),构建时没有错误。

我可以在具有 x64 配置文件的文件系统上发布。但是,当尝试使用目标运行时“win7-x86”发布时,会出现以下错误:

Could not find a part of the path 'c:\Users\Developer\Documents\Visual Studio 2015\Projects\SelfHostTest\src\SelfHostTest\bin\Release\net452\win7-x86\SelfHostTest.exe'

我使用 Windows 8.1 x64 计算机。我进入“配置管理器”并将“平台”从“任何 CPU”更改为“x86”,但不起作用。

我注意到有一个文件夹“src\SelfHost2\bin\Debug\net452\win7-x64”,但我没有做任何事情来创建 x86 的结构。

此发布有效:

enter image description here

此发布不起作用:

enter image description here

这是我的project.json,以帮助别人帮助我。

{
  "dependencies": {
    "Microsoft.AspNetCore.Diagnostics": "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.Server.WebListener": "0.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "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"
  },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "net452": {
      "dependencies": {
      }
    }
  },

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

  "runtimes": {
    "win7-x64": {},
    "win7-x86": {}
  },

  "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%" ]
  },

  "commands": {
    "http": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000"
  }
}

最佳答案

这是工具中的错误。它将始终针对默认 RID 进行构建(据我所知,无法更改它),但随后在发布对话框中,您会看到 project.json 中的所有 RID,如果您选择非默认,则发布将会失败,因为该项目不是为此 RID 构建的。尝试使用您要发布的 RID 从命令行进行构建。这样,当您发布时,VS 将能够找到二进制文件并且发布应该可以工作。

关于asp.net-mvc - 发布 .NET Core 应用程序时出现错误 "Could not find a part of the path",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39023224/

相关文章:

unit-testing - Visual Studio 测试资源管理器窗口将无法打开

c# - 我应该在 Model 还是 viewModel 中放置 "required"数据注释?

asp.net-mvc - 使用带有 spark View 引擎的 asp.net mvc 2 功能

jquery - 选择最后动态添加的文本框

c# - 如何将一个 for 循环分成多个循环并使用线程运行它们以缩短运行时间?

VB.NET Visual Basic Power Pack 在 VS2015 上不起作用?

asp.net - Entity Framework 7 - 访问相关实体

c# - 使用 Entity Framework 从 Excel 工作表中读取数据

c# - 尝试编辑不存在的项目的最佳实践?

asp.net-mvc - 如何使用 Globalize.js 为 ASP.NET Core MVC 中的客户端验证配置文化