繁体   English   中英

dotnet核心在ubuntu 14.04新贵问题上

[英]dotnet core on ubuntu 14.04 upstart issue

我在ubuntu 14.04 vm上运行了dotnet core 1.0。 我正在尝试为部署过程编写一个upstart脚本:

start on filesystem and started networking
respawn
chdir /home/dotnetuser/dotnetportal/
exec sudo /usr/bin/dotnet restore
exec sudo /usr/bin/dotnet run

运行此服务后,我验证日志并获得通常预期的内容(来自本地/开发vm测试):

Hosting environment: Production
Content root path: /home/dotnetuser/dotnetportal
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.

我在我的域和ssl的nginx反向代理上有localhost:5000:

server {
   # Enable HTTP/2
       listen 443 ssl; #http2;
       listen [::]:443 ssl; #http2;
       server_name portal.secret.com;

       # use the lets encrypt certificates
       ssl_certificate /etc/letsencrypt/live/portal.secret.com/fullchain.pem;
      ssl_certificate_key /etc/letsencrypt/live/portal.secret.com/privkey.pem;

      # include the SSL configuration from cipherli.st
      include snippets/ssl_params.conf;

     location / {

         proxy_pass http://localhost:5000;
         proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
         proxy_set_header Host $host;
         proxy_cache_bypass $http_upgrade;
     }

}

但是,当我卷曲https://portal.secret.com/我再次验证日志时,我得到了一堆编译器错误。

请记住,直接从工作生产文件夹运行dotnet运行时我不会出现任何错误,我可以访问该站点。

我尝试从服务运行网站时的日志是:

an unhandled exception has occurred: Can not find compilation library location for package '    microsoft.aspnetcore.antiforgery'
 18 System.InvalidOperationException: Can not find compilation library location for package 'microsoft    .aspnetcore.antiforgery'
 19    at Microsoft.Extensions.DependencyModel.CompilationLibrary.ResolveReferencePaths()
 20    at System.Linq.Enumerable.<SelectManyIterator>d__157`2.MoveNext()
 21    at Microsoft.AspNetCore.Mvc.Razor.Compilation.MetadataReferenceFeatureProvider.PopulateFeature(    IEnumerable`1 parts, MetadataReferenceFeature feature ETC.....

有没有人有任何见解,为什么只有在我启动服务而不是直接运行命令时才会发生这种情况?

更新:这是我的Project.json

{
  "userSecretsId": "xxxxx",

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "System.Runtime.Loader": "4.0.0",
    "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.1",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.0.1",
    "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.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-update1",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.0.0-preview2-update1",
      "type": "build"
    },
    "MongoDB.Driver" : "2.3.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    },
    "Microsoft.Extensions.SecretManager.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": "portable-net45+win8+dnxcore50"
    },
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.0.0-preview2-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

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

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "npm install", "bower install", "gulp clean", "gulp min" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  },

  "tooling": {
    "defaultNamespace": "WebApplication"
  }
}

我通过删除/ tmp / NuGetScratch文件夹解决了这个问题,并且明确地告诉linux哪个用户运行应用程序。 更新的服务配置脚本是:

start on filesystem and started networking
respawn
 setuid dotnetuser
 env HOME=/home/dotnetuser
 exec rm -rf /tmp/NuGetScratch/
 chdir /home/dotnetuser/apps/dotnetportal
 exec dotnet restore
 exec dotnet run

问题是.net没有编译,因为我删除的目录(tmp / NuGetScratch)中找到的nuget锁文件导致了文件权限问题。 我想现在.net希望你以root身份运行 - 在此发现: https//github.com/dotnet/dotnet-docker/issues/78 (NuGet缓存填充失败,因为/ tmp / NuGetScratch由root拥有或其他一些su)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM