Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.6k views
in Technique[技术] by (71.8m points)

msbuild - dotnet publish command is not creating zip file package for asp.net core web application project

I am trying to create a web deployment package for asp.net core web application. When I tried to publish the output as a package using VS2017, I got all the necessary files in "Publish" folder as well a zip file containing all those files in given location.

However I want to have the same using command line. I am able to get "Publish" folder, but not a zip file. What am I doing wrong? Can someone correct my command?

dotnet publish /p:target=package /p:WebPublishMethod=Package /p:LastUsedBuildConfiguration=Release /p:LastUsedPlatform="Any CPU" /p:LaunchSiteAfterPublish=True /p:ExcludeApp_Data=False /p:PublishFramework=netcoreapp1.0 /p:UsePowerShell=True /p:DesktopBuildPackageLocation=C:KannanTemppackage.zip /p:PackageLocation="C:kannanemppackage.zip" /p:PackageFileName=C:kannanemppackage.zip /p:PackageAsSingleFile=true
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

What am I doing wrong? Can someone correct my command?

It`s depends on the version of your cli.

If you are using the 2.0 version of cli, then you can use dotnet publish command on a windows machine and it would work.

dotnet build WebApplicationDeploy.sln /nologo /p:PublishProfile=Release /p:PackageLocation="C:SomePathpackage" /p:OutDir="C:SomePathout" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /maxcpucount:1 /p:platform="Any CPU" /p:configuration="Release" /p:DesktopBuildPackageLocation="C:SomePathpackagepackage.zip"

But if you are using 1.0.4 version of the cli, then you should use the msbuild version of the command (The ability to call dotnet build was added in 2.0 cli).

msbuild WebApplicationDeploy.sln /nologo /p:PublishProfile=Release /p:PackageLocation="C:SomePathpackage" /p:OutDir="C:SomePathout" /p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /maxcpucount:1 /p:platform="Any CPU" /p:configuration="Release" /p:DesktopBuildPackageLocation="C:SomePathpackagepackage.zip"

For the detail info, you can refer to the same issue on GitHub.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...