question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to publish on command line using publish profile

See original GitHub issue

I’m trying to automate the publishing of a .Net Core app on the Mac/Linux command line using the “dotnet” tool. No command I’ve tried has resulted in the project getting published to the folder the publish profile specifies. The publish profile works when I use Visual Studio for Mac to directly publish the project. I’ve tried many variations of both the dotnet publish -p:PublishProfile=... command and also dotnet build -p:DeployOnBuild=True -p:PublishProfile=.... It looks like it’s silently ignoring the PublishProfile I give it, and indeed the output doesn’t look materially different if I give it an intentionally bad path.

I’ve tried specifying the csproj and not, pwd in the solution directory and in the project directory, and nothing seems to work except using Visual Studio instead of the dotnet CLI.

I’m running on a Mac running 10.15.5, and CentOS 7, both with dotnet 3.1.301.

My publish profile is the default folder publishing profile, named Properties/PublishProfiles/DockerImage.pubxml:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>AnyCPU</LastUsedPlatform>
    <publishUrl>docker-image</publishUrl>
    <DeleteExistingFiles>true</DeleteExistingFiles>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <SelfContained>false</SelfContained>
    <_IsPortable>true</_IsPortable>
  </PropertyGroup>
</Project>

I see this output, indicating the app was published to the default directory instead of the docker-image folder I specified:

> dotnet publish -p:PublishProfile=ProjectName/Properties/PublishProfiles/DockerImage.pubxml

  Determining projects to restore...
  All projects are up-to-date for restore.
  ProjectName -> /Users/dfrankel/Projects/Solution Name/ProjectName/bin/Debug/netcoreapp3.1/ProjectName.dll
  ProjectName -> /Users/dfrankel/Projects/Solution Name/ProjectName/bin/Debug/netcoreapp3.1/publish/

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:11
  • Comments:47 (15 by maintainers)

github_iconTop GitHub Comments

10reactions
falvarez1commented, Sep 30, 2020

I’m experiencing the same bug with dotnet publish using the PublishProfile. The following works and gets published to bin\Release\PublishOutput folder: dotnet build /p:DeployOnBuild=True /p:Configuration=Release /p:PublishProfile=FranksFolderProfile

However, using publish with the same profile ignores the publishUrl field in the profile: dotnet publish /p:Configuration=Release /p:PublishProfile=FranksFolderProfile This ends up in the folder bin\Release\netcoreapp3.1\win7-x64\publish

Here’s what my pubxml file looks like:

<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>win7-x64</RuntimeIdentifier>
    <ProjectGuid>40aa877f-1206-408a-8d96-ab1f8f84e75b</ProjectGuid>
    <publishUrl>bin\Release\PublishOutput</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
    <SelfContained>true</SelfContained>
    <_IsPortable>true</_IsPortable>
    <PublishReadyToRun>True</PublishReadyToRun>
  </PropertyGroup>
</Project>
6reactions
hallambakercommented, Mar 1, 2022

It still doesn’t work for me. This is broken and there are multiple issues. I keep opening issues and getting fobbed off. Told I am complaining to the wrong group.

  1. The documentation is atrocious, stop blaming developers

  2. All I want to do is to automate the publish command that I can use INSIDE Visual studio externally. I have 5 deliverables with ten platforms each I should not have to incrementally publish each one manually.

The missing command is a Visual Studio command Build -> Publish Solution -> ALL

  1. Pick one of dotnet publish / dotnet build / msbuild and stick to it.

  2. IF A PUBLISH PROFILE IS SPECIFIED IT SHOULD BE USED OR AN ERROR REPORTED

I have tried numerous variations of this command:

dotnet publish C:\Users\hallam\Work\mmm\Applications\meshhost\meshhost.csproj -c release /p:PublishProfile=publish-win-x64

They all fail in exactly the same way if I specify a non existent profile.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to publish ASP.NET web site using command line
MY Command line output show only "build successfully" of the solution but nothing about the publish profile. The same solution and batch file ......
Read more >
Visual Studio publish profiles (.pubxml) for ASP.NET Core ...
Learn how to create publish profiles in Visual Studio and use them for managing ASP.NET Core app deployments to various targets.
Read more >
Publish with Msbuild - Developer Community
According to your example I tried this command line. Build succeeded but still no file into the publish directory. msbuild .\ihm\ihm\ihm.csproj ...
Read more >
Publish to a RoboHelp Server
Choose Edit > Publish Profiles. The Publish Settings dialog box opens. Click to create a new profile.
Read more >
Visual Studio publish profiles for ASP.NET Core app deployment
The easiest way to publish with MSDeploy is to first create a publish profile in Visual Studio. 2017 and use the profile from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found