5

Tôi có một ứng dụng web lõi .NET rất đơn giản (.NET Framework) được tạo bằng Visual Studio 2015 Update 3 được xây dựng mà không có lỗi.Lỗi "Không thể tìm thấy một phần của đường dẫn" trong khi xuất bản .NET Core Application

Tôi có thể xuất bản trên hệ thống tệp có cấu hình x64. Tuy nhiên, khi cố gắng xuất bản với thời gian chạy mục tiêu "win7-x86", hãy cung cấp lỗi sau:

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'

Tôi sử dụng máy 8.1 x64 của Windows. Tôi đã đi đến "Trình quản lý cấu hình" và thay đổi "Nền tảng" từ "Bất kỳ CPU" thành "x86" nhưng không hoạt động.

Tôi nhận thấy có một thư mục "src \ SelfHost2 \ bin \ Debug \ net452 \ win7-x64" nhưng không có gì tôi tạo ra cấu trúc cho x86.

này xuất bản các tác phẩm:

enter image description here

này xuất bản không hoạt động:

enter image description here

Dưới đây là project.json của tôi để giúp một ai đó giúp tôi.

{ 
    "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" 
    } 
} 

Trả lời

8

Đây là lỗi trong công cụ. Nó sẽ luôn luôn xây dựng cho RID mặc định (và AFAIK không có cách nào để thay đổi nó) nhưng sau đó trong hộp thoại xuất bản bạn thấy tất cả các RID từ project.json và nếu bạn chọn một xuất bản không mặc định sẽ thất bại kể từ khi dự án không được xây dựng cho RID này. Thử xây dựng từ dòng lệnh bằng RID bạn muốn xuất bản. Bằng cách này khi bạn đang xuất bản VS sẽ có thể tìm thấy các tệp nhị phân và xuất bản sẽ hoạt động.

+0

Ok. Tôi đã viết trên console của máy phát triển của tôi "dotnet publish --configuration Release --runtime win7-x86". Nó tạo ra một thư mục "Release \ net452 \ win7-x86". Tôi đã sao chép nội dung vào windows7 của mình. Tôi chạy exe, và tôi đã nhận được lỗi phàn nàn về x86/x64 – Murilo

+0

Hãy thử thêm '" platform ":" x86 "' vào 'buildOptions' trong project.json của bạn khi xây dựng cho x86 – Pawel

+0

Điều đó đã làm việc! Nhưng hãy để tôi hỏi: khi xuất bản lên x64 nó sẽ thực sự là x64? – Murilo

Các vấn đề liên quan