Almost 2 years ago I wrote a blog post on creating WebDeploy packages (really MSDeploy packages) for ASP.NET Core projects.
https://www.dotnetcatch.com/2016/09/20/webdeploy-packaging-with-asp-net-core/
Since that time there have been changes to the framework and that solution no longer works with ASP.NET Core 2.0 projects. The PackagePublish and Publish targets for example are no longer provided.
>”c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild” /t:PackagePublish
Microsoft (R) Build Engine version 15.7.179.6572 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.Build started 6/13/2018 12:53:00 PM.
Project “c:\users\jdoe\source\repos\App2\WebApplication1\WebApplication1.csproj” on node 1 (PackagePublish ta
rget(s)).
c:\users\jdoe\source\repos\App2\WebApplication1\WebApplication1.csproj : error MSB4057: The target “PackagePublish” does not exist in the project.
Done Building Project “c:\users\jdoe\source\repos\App2\WebApplication1\WebApplication1.csproj” (PackagePublis
h target(s)) — FAILED.Build FAILED.
“c:\users\jdoe\source\repos\App2\WebApplication1\WebApplication1.csproj” (PackagePublish target) (1) ->
c:\users\jdoe\source\repos\App2\WebApplication1\WebApplication1.csproj : error MSB4057: The target “Package
Publish” does not exist in the project.0 Warning(s)
1 Error(s)Time Elapsed 00:00:00.27
However you can still package ASP.NET Core 2.0 projects using the DeployOnBuild and WebPublishMethod properties:
>”c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild” /p:DeployOnBuild=true /p:WebPublishMethod=package
…
Package “FunctionApp1.zip” is successfully created as single file at the following location:
file:///c:/users/jdoe/source/repos/App2/FunctionApp1/bin/Debug/net461
To get the instructions on how to deploy the web package please visit the following link:
http://go.microsoft.com/fwlink/?LinkId=124618
Done Building Project “c:\users\jdoe\source\repos\App2\FunctionApp1\FunctionApp1.csproj” (default targets).Build succeeded.
0 Warning(s)
0 Error(s)Time Elapsed 00:00:04.24
Not sure the why they made this change but it is more similiar to the old full framework MSBuild arguments for packaging.
Notice too that this works with Function Apps as well which is a nice benefit.
Happy Building!