zoukankan      html  css  js  c++  java
  • .NET 5.0 单文件发布配置

    上图

    AppSettingsHelper代码,

     标红的部分,要按照这个来,否则会提示找不到appsettings.json文件

    The configuration file 'appsettings.json' was not found and is not optional. The physical path is '/root/.net/app/1jlu02hd.xkf/appsettings.json'.
            public static IConfiguration Configuration { get; set; }
            static AppSettingsHelper()
            {
                Configuration = new ConfigurationBuilder()
                //.Add(new JsonConfigurationSource { Path = "appsettings.json", ReloadOnChange = true })
                .SetBasePath(GetBasePath())
                .AddJsonFile("appsettings.json",false,true)
                .Build();
            }
            private static string GetBasePath()
            {
                using var processModule = Process.GetCurrentProcess().MainModule;
                return Path.GetDirectoryName(processModule?.FileName);
            }

    发布配置文件 FolderProfile.pubxml 代码如下

    标红的部分要加,否则会提示

     System.NotSupportedException: CodeBase is not supported on assemblies loaded from a single-file bundle.
    <?xml version="1.0" encoding="utf-8"?>
    <!--
    https://go.microsoft.com/fwlink/?LinkID=208121. 
    -->
    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <DeleteExistingFiles>True</DeleteExistingFiles>
        <ExcludeApp_Data>False</ExcludeApp_Data>
        <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
        <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
        <LastUsedPlatform>Any CPU</LastUsedPlatform>
        <PublishProvider>FileSystem</PublishProvider>
        <PublishUrl>binRelease
    et5.0publish</PublishUrl>
        <WebPublishMethod>FileSystem</WebPublishMethod>
        <SiteUrlToLaunchAfterPublish />
        <TargetFramework>net5.0</TargetFramework>
        <RuntimeIdentifier>linux-x64</RuntimeIdentifier>
        <PublishSingleFile>True</PublishSingleFile>
        <PublishTrimmed>False</PublishTrimmed>
        <ProjectGuid>5d4244e1-d03a-4986-8c8a-cbfd1310af0e</ProjectGuid>
        <SelfContained>true</SelfContained>
        <IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
      </PropertyGroup>
    </Project>

     生成的文件有点大,不过清爽了好多

  • 相关阅读:
    http-server -S 开启 https 服务
    material-ui react的ui框架 有时间可以看看 chia用的前台ui
    关于vue.js:iview-Bug-5114在iview的Poptip气泡提示内调用DatePicker出现遮挡或同时关闭窗口等冲突问题[转]
    coding 的pages 静态要六分钱一个月,我也是醉了。
    jeesite 有时间看看
    选择单词后 按 ctrl + space 单词发音
    什么是CI/CD
    PostCSS深入学习: PostCSS和Sass、Stylus或LESS一起使用
    浅析requestAnimationFrame
    webpack性能优化
  • 原文地址:https://www.cnblogs.com/icejd/p/14826004.html
Copyright © 2011-2022 走看看