发布 .NET Core 应用程序时出错 "Could not find a part of the path"

Error "Could not find a part of the path" while publishing .NET Core Application

我有一个使用 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 机器。我去了 "Configuration Manager" 并将 "Platform" 从 "Any CPU" 更改为 "x86" 但没有用。

我注意到有一个文件夹 "src\SelfHost2\bin\Debug\net452\win7-x64",但我没有为 x86 创建结构。

此发布作品:

此发布无效:

这是我的 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 构建(并且 AFAIK 无法更改它)但是随后在发布对话框中您会看到来自 project.json 的所有 RID,如果您 select 是非默认 RID发布将失败,因为项目不是为此 RID 构建的。尝试使用您要发布的 RID 从命令行构建。这样当你发布时 VS 将能够找到二进制文件并发布应该工作。