.net core发布的几种方式,不需要安装sdk的发布方式等。起始地址,起始端口配置,发布不同环境 电脑版发表于:2021/9/16 15:20 #### 使用dotnet publish --help可以查看发布参数 ``` dotnet publish --help ```  #### 比如发布的时候输出一个具体的位置 使用 --output即可 ``` dotnet publish --output D:\fb\wy_jbland ``` #### 不需要安装sdk的发布方式 **主要是使用--self-contained**  ``` dotnet publish --self-contained true --output D:\fb\wy_jbland ``` 但是这样会报错:  提示还要使用版本,其实在help里边也有说明的:  ``` dotnet publish --runtime net5.0 --self-contained true --output D:\fb\wy_jbland ``` 如果名字输出了也会报错:  **要使用下面的方式:** 这里指定的是win10-x64: ``` dotnet publish --runtime win10-x64 --self-contained true --output D:\fb\wy_jbland2 ``` 也可以直接win-x64: ``` dotnet publish --runtime win-x64 --self-contained true --output D:\fb\wy_jbland2 ``` 或者是linux的版本,或者mac版本 **报错 MSBUILD : error MSB1009: 项目文件不存在。**  **报错:Non-HTTPS access will be removed in a future version. Consider migrating to an 'HTTPS' source.** 这个情况是nuget使用了http,就不行。  取消勾选就行 **发布出来之后运行:** 直接点击exe:  或者使用命令行输入名字:  **设置起始页,设置访问端口** ``` public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); webBuilder.UseUrls("http://*:8002"); }).UseAutofac(); ``` #### 其实在vs中发布的时候其实也可以选择  https://www.likecs.com/show-65249.html