簡體   English   中英

dotnet發布配置文件CLI與Visual Studio的行為不同

[英]dotnet publish profile CLI vs Visual Studio behave different

我有一個dotnet核心2.1 Web API項目,其發布配置文件到最近我計划復制到IIS的文件夾,如dotnet發布文檔中所述

我用VS創建了發布配置文件,結果文件是

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <PublishProvider>FileSystem</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <ProjectGuid>b3155c62-817f-4eba-8856-e5941137f4ed</ProjectGuid>
    <SelfContained>true</SelfContained>
    <_IsPortable>false</_IsPortable>
    <publishUrl>bin\publish\</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
  </PropertyGroup>
</Project>

如果我從VS運行配置文件,它會創建一個bin\\publish文件夾,我可以將其復制到IIS。

如果我在更新到最新的VS之后使用dotnet publish /p:PublishProfile=FolderProfile (如在CI服務器中)那樣做,我會收到以下錯誤

C:\\Program Files\\dotnet\\sdk\\2.1.400\\Sdks\\Microsoft.NET.Sdk\\targets\\Microsoft.NET.RuntimeIdentifierInference.targets(122,5): error NETSDK1067: Self-contained applications are required to use the application host. Either set SelfContained to false or set UseAppHost to true. [C:\\Users\\Guillem.Sola\\source\\repos\\ASG.DHW.HealthCheck\\ASG.DHW.HealthCheck.API\\ASG.DHW.HealthCheck.API.csproj]

我可以在cmd中實現類似的激勵

dotnet publish .\\HealthCheck.API\\HealthCheck.API.csproj -o .\\bin\\publish -r win-x64 -c Release

發生了什么,為什么從CLI調用時配置文件的行為不一樣?

我認為您(更新)問題的關鍵可能在錯誤消息的這一部分:

使用應用程序主機需要自包含的應用程序。 將SelfContained設置為false或將UseAppHost設置為true。

行為的差異很容易通過許多因素來解釋,例如,各種VS條件帶來的MSBuild目標文件。

因為您不想使用AppHost,所以您需要將<SelfContained>true</SelfContained>更改為<SelfContained>false</SelfContained> 您還可以考慮添加顯式<UseAppHost>false</UseAppHost> - 這可能有助於緩解VS和CI構建之間的差異。

打開/關閉MSBuild詳細程度是獲取更多數據的好方法,可幫助您了解操作具有觀察結果的原因。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM