Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create MSdeploy Package using MSBuild for all files in this project folder

I'm trying to create a web deploy package using msbuild through command line. I have been searching all over and found the following command

 msbuild myproject.csproj /t:package

Though it works for me but it gives me only what visual studio gives us back when we create web deploy package through Packge/Publish Web tab with "only files needed to run this application" option selected from the drop down menu. But I want my web deploy package to look exactly the same as what I get when I select "All files in this project folder" option from the drop down menu. I have gone through links like this http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx.

But I wonder that do I really need to customize my .csproj file (the way its been described in that post) since all I want, is a command line (apparently more elaborate than the one I mentioned above) for msbuild that can imitate the "All files in this project folder" option that populates the "bin folder of web deploy package" with all the .dlls that are there in the original bin folder of my project and generate me a more comprehensive package.

like image 448
user2913184 Avatar asked May 01 '15 23:05

user2913184


People also ask

How do I publish a Visual Studio solution from the command-line?

Basic command-line publishingThe default publish folder format is bin\Debug\{TARGET FRAMEWORK MONIKER}\publish\. For example, bin\Debug\netcoreapp2. 2\publish\. The dotnet publish command calls MSBuild, which invokes the Publish target.

What is publish profile in MSBuild?

A publish profile is just an MSBuild file. When you pass in PublishProfile and DeployOnBuild=true, then the publish profile is Imported into the build/publish process. It will supply the publish properties needed to perform the publish. Let's see how that works.

What is WebPublishMethod?

"WebPublishMethod" ensures we are just creating a deployment package. There are other options like publishing to the file system or elsewhere using MSDeploy. "PackageAsSingleFile" will zip up the output into a single file. "PackageLocation" is where the zip will be saved.


1 Answers

In your commandline simply add /p:FilesToIncludeForPublish=AllFilesInProjectFolder to your msbuild invocation. While you're at it, you may also want to pass in a specific configuration to build /p:Configuration=Release

So:

 msbuild myproject.csproj /t:package /p:FilesToIncludeForPublish=AllFilesInProjectFolder /p:Configuration=Release

Tip: Many of these settings are stored in your project file. Open up your file in Notepad and compare the changes made when you have changed some settings. Any item that's in a <propertygroup> can usually be passed along through the commandline as well using the /p: parameter.

like image 58
jessehouwing Avatar answered Oct 05 '22 20:10

jessehouwing