Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# dotnet发布配置文件忽略pubxml文件_C#_Asp.net_.net_.net Core_Msbuild - Fatal编程技术网

C# dotnet发布配置文件忽略pubxml文件

C# dotnet发布配置文件忽略pubxml文件,c#,asp.net,.net,.net-core,msbuild,C#,Asp.net,.net,.net Core,Msbuild,我通过Visual Studio 2019创建了以下pubxml文件: <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <WebPublishMethod>FileSystem</WebPublishMethod> <Pub

我通过Visual Studio 2019创建了以下pubxml文件:

<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>netcoreapp3.1</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <ProjectGuid>143a6329-27d9-474e-9521-835be634c293</ProjectGuid>
    <SelfContained>true</SelfContained>
    <publishUrl>bin\Release\netcoreapp3.1\publish\</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
  </PropertyGroup>
</Project>
以及pubxml的路径

src\MyProject.Web\Properties\PublishProfiles\ProductionPublish.pubxml

您需要使用以下命令:

dotnet build -c Release /p:DeployOnBuild=true /p:PublishProfile=FolderProfile
  • 它是
    build
    ,而不是
    publish

  • 即使我的FolderProfile的配置设置为Release,我也必须 包括
    -c版本
    ,因为构建了其他相关项目 使用调试配置

  • 如果在没有
    /p:DeployOnBuild=true的情况下调用,则不会将文件复制到目标位置

  • 只需名称
    FolderProfile
    (不带扩展名)就足够了
    配置文件。或者您可以提供路径
    /p:PublishProfile=Properties\PublishProfiles\FolderProfile.pubxml


请参阅Microsoft文档。

您是否在“解决方案”下有“属性”文件夹?或者在解决方案中的某个项目下?更新了我的帖子,请检查您是否正在尝试发布解决方案。您应该从MyProject.Web文件夹运行
dotnetpublish
命令。这将发布您可以部署到web服务器的web应用程序。当从Web项目文件夹运行时,您不需要将
src\MyProject.Web.sln
参数传递到
dotnet publish
命令。我切换到您所说的
dotnet.exe publish Radius.MicroServices.CySec.Web.csproj-p:PublishProfile=Properties\PublishProfiles\ProductionPublish.pubxml
,结果仍然是相同的唯一对我有效的解决方案。我想通过“dotnet publish”使用发布配置文件,并将该配置文件作为参数传递,但它从未起作用。这解决了我的问题,谢谢!
dotnet build -c Release /p:DeployOnBuild=true /p:PublishProfile=FolderProfile