Unable to publish on command line using publish profile
See original GitHub issueI’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:
- Created 3 years ago
- Reactions:11
- Comments:47 (15 by maintainers)
Top GitHub Comments
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\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.