Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet publish profile ignores pubxml file

I have the following pubxml file which I created via Visual Studio 2019:

<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>

When I run dotnet.exe publish src\MyProject.Web.sln -p:PublishProfile=Properties\PublishProfiles\ProductionPublish.pubxml Release does not contain anything and publish happens on Debug folder (debug build). Whys does this happens and pubxml is ignored?

Update #1

Structure
src\MyProject\MyProject.csproj
src\MyProject.Utils\ect.Utils.csproj
src\MyProject.Web\MyProject.Web.csproj
src\MyProject.Web.sln

and the path of the pubxml

src\MyProject.Web\Properties\PublishProfiles\ProductionPublish.pubxml
like image 857
pantonis Avatar asked Dec 07 '22 10:12

pantonis


1 Answers

You need the use following command:

dotnet build -c Release /p:DeployOnBuild=true /p:PublishProfile=FolderProfile
  • It's build, not publish.

  • Even if my FolderProfile's configuration is set to Release, I had to include -c Release because otherwise dependent projects were built with debug configuration.

  • Files not copied to target location if called without /p:DeployOnBuild=true.

  • Just the name FolderProfile -without extension- is enough for the
    profile file. Or you can give the path
    /p:PublishProfile=Properties\PublishProfiles\FolderProfile.pubxml

See Folder publish example from Microsoft Docs.

like image 157
palindrom Avatar answered Dec 27 '22 02:12

palindrom