无法发布.NET Core Web Application(无法加载文件或程序集Microsoft.DotNet.ProjectModel)

时间:2016-07-21 19:05:37

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

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

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

我想我的项目可能有问题,但是按照这些步骤创建一个空白模板项目我遇到了完全相同的问题:

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

2 - 右键点击项目=> Publish =>选择了我的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,但都没有。我错过了什么?

3 个答案:

答案 0 :(得分:2)

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

您可以通过包管理器控制台尝试Install-Package Microsoft.DotNet.ProjectModel -Pre吗?或右键单击项目并选择Manage NuGet Package并搜索Microsoft.DotNet.ProjectModel并安装它。

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

根据评论更新

尝试以下步骤展示。

  1. 创建一个新的.Net核心Web应用程序。
  2. 右键单击引用,然后选择“管理NuGet包”。
  3. 在“浏览”部分下搜索Microsoft.DotNet.ProjectModel。 - 注意:您需要选择预发布选项。
  4. 安装完成后,您将能够看到这一点。

    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

答案 1 :(得分:1)

发布到Azure时,我遇到了完全相同的错误。对我有帮助的是将project.json中的Microsoft.AspNetCore.Server.IISIntegration.Tools更改为1.0.0-preview1-final:

{
    "size":0,
   "query": {
     "nested": {
                  "path":"appPartner",
                  "query": {
                    "bool": {
                      "must": [
                        {"match": {"appPartner.id": "1"}}
                      ]
                    }
                  }
                }
   },
   "aggs": {
      "packs" : {
          "nested" : {
              "path" : "packs"
          }, 
           "aggs" : {
              "id" : {
                  "terms" : {
                      "field" : "packs.id"
                  }
              ,
              "aggs":{
                  "name":{
                    "terms" : {
                          "field" : "packs.name"
                      }
                  }
             }
             }
          }       

      }
   }
}

我必须说我不知道​​为什么这样有效,所以欢迎任何见解

答案 2 :(得分:0)

由于我无法从其他任何人那里获得重复,我重新安装了操作系统,Visual Studio以及我工作站上的所有内容,现在它正在运行。仍然不确定底层问题来自哪里,但似乎是在ASP.NET Core 1.0发布的某个时候在我的机器上输入的奇怪状态