gpt4 book ai didi

c# - 无法发布 .NET Core Web 应用程序(无法加载文件或程序集 Microsoft.DotNet.ProjectModel)

转载 作者:太空宇宙 更新时间:2023-11-03 23:12:39 25 4
gpt4 key购买 nike

我一直在尝试发布我的应用程序,但总是遇到错误:

System.IO.FileNotFoundException:无法加载文件或程序集“Microsoft.DotNet.ProjectModel,Version=1.0.0.0,Culture=neutral,PublicKeyToken=adb9793829ddae60”。系统找不到指定的文件。

我认为我的项目可能有问题,但按照以下步骤创建空白模板项目,我遇到了完全相同的问题:

1 - Visual Studio 2015(已安装更新 3 和补丁)=> 文件 => 新建 => 项目 => 具有单独用户帐户的 ASP.NET Core Web 应用程序 (.NET Core)

2 - 右键单击​​项目 => 发布 => 选择我的 Azure 配置文件 => 单击发布

3 - 发布失败并出现上述错误

这是我的project.json:

  "dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.0",
"type": "platform"
},
"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"
},
"Microsoft.DotNet.ProjectModel": "1.0.0-rc3-003121"
},

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

我尝试在 Nuget 中找到丢失的包,并尝试将其手动添加到 project.json,但都没有成功。我错过了什么?

最佳答案

真的,我在配置文件中没有看到 ProductModel。

您能否通过包管理器控制台尝试Install-Package Microsoft.DotNet.ProjectModel -Pre。或右键单击该项目并选择“管理 NuGet 包”并搜索 Microsoft.DotNet.ProjectModel 并安装它。

然后检查package.json,必须有一个部分Microsoft.DotNet.ProjectModel

根据评论更新

尝试了以下步骤来显示。

  1. 创建一个新的 .Net Core Web 应用程序。
  2. 右键单击“引用”并选择“管理 NuGet 包”。
  3. 在浏览部分中搜索 Microsoft.DotNet.ProjectModel。 - 注意:您需要选择预发布选项。

安装后您将能够看到这一点。

enter image description here

尝试发布到我的本地驱动器本身并发布,没有任何问题

enter image description here

完整的构建日志,

1>------ Build started: Project: dotmodelissue, Configuration: Release Any CPU ------
1> C:\Program Files\dotnet\dotnet.exe build "E:\Thenna\StackOverFlow\dotmodelissue" --configuration Release --no-dependencies
1> Project dotmodelissue (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing
1> Compiling dotmodelissue for .NETCoreApp,Version=v1.0
1> Compilation succeeded.
1> 0 Warning(s)
1> 0 Error(s)
1> Time elapsed 00:00:01.7973890
1>
2>------ Publish started: Project: dotmodelissue, Configuration: Release Any CPU ------
Connecting to E:\ddd...
Environment variables:
Path=.\node_modules\.bin;D:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;%PATH%;D:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External\git
C:\Program Files\dotnet\dotnet.exe publish "E:\Thenna\StackOverFlow\dotmodelissue" --framework netcoreapp1.0 --output "C:\Users\thenna\AppData\Local\Temp\PublishTemp\dotmodelissue57" --configuration Release --no-build
Publishing dotmodelissue for .NETCoreApp,Version=v1.0
Configuring the following project for use with IIS: 'C:\Users\thenna\AppData\Local\Temp\PublishTemp\dotmodelissue57'
Updating web.config at 'C:\Users\thenna\AppData\Local\Temp\PublishTemp\dotmodelissue57\web.config'
Configuring project completed successfully
publish: Published to C:\Users\thenna\AppData\Local\Temp\PublishTemp\dotmodelissue57
Published 1/1 projects successfully
Publishing with publish method [FileSystem]
Publishing files to E:\ddd
Executing command ["C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -source:manifest='C:\Users\thenna\AppData\Local\Temp\PublishTemp\obj\dotmodelissue57\SourceManifest.xml' -dest:manifest='C:\Users\thenna\AppData\Local\Temp\PublishTemp\obj\dotmodelissue57\DestinationManifest.xml' -verb:sync -retryAttempts:20 -disablerule:BackupRule]
Total changes: 204 (125 added, 79 deleted, 0 updated, 0 parameters changed, 5540847 bytes copied)

Web App was published successfully file:///E:/ddd

========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Publish: 1 succeeded, 0 failed, 0 skipped ==========

发布到 Azure

enter image description here

关于c# - 无法发布 .NET Core Web 应用程序(无法加载文件或程序集 Microsoft.DotNet.ProjectModel),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38512468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com