sdk: Unable to publish on command line using publish profile
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/
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 11
- Comments: 47 (15 by maintainers)
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=FranksFolderProfileHowever, using publish with the same profile ignores the publishUrl field in the profile:
dotnet publish /p:Configuration=Release /p:PublishProfile=FranksFolderProfileThis ends up in the folder bin\Release\netcoreapp3.1\win7-x64\publishHere’s what my pubxml file looks like:
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.
The documentation is atrocious, stop blaming developers
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
Pick one of dotnet publish / dotnet build / msbuild and stick to it.
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.
@wolfding @mcflux @imjustalf @guidomocha - This issue once fixed should address most of the above issues. https://github.com/dotnet/sdk/issues/20931
PublishUrlis used by Visual Studio to denote the Publish target.PublishDiris used by CLI to denote the Publish target.If you want the scenario to work in all places, You can initialize both these properties to the same values in the pubxml and the scenario will work in all places.
The reason we can’t change VS to use
PublishDiris becausePublishDirwas created later & VS in older versions still rely onPublishUrl. So, once the default in CLI is fixed, it should take care of all issues.If you are still running into issues, I am happy to take a look.
@vijayrkn I find something interesting. I encounter the same problem, and I changed the pubxml as your modified pubxml, it works. Compare to the VS-generated pubxml, I found the main difference is PublishUrl and PublishDir. I changed the VS-generated PublishUrl => PublishDir, everything works fine.
What’s the difference between PublishUrl and PublishDir?
@willnationsdev - Let me see what I can find.
Others, please use the msbuild work-around for now, until I figure out a way to do this correctly.
I noticed as well that the publish profile is ignored when using dotnet publish. It doesnt occure if you use build and set -p:DeployOnBuild=True but I build the project in my pipeline before this is clearly missing if it doesnt work with publish.
I will have to see how VS Mac is using this profile. Adding some additional properties might fix this. I will take a look.
@abbeycode - I will take a look today and get back before the end of day.