9

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.

user2913184
  • 590
  • 10
  • 33

1 Answers1

8

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.

jessehouwing
  • 106,458
  • 22
  • 256
  • 341
  • Thanks a lot for your answer I will try it and let you know, meanwhile can you please elaborate little bit more on what you said in your answer like "Open up your file in Notepad and compare the changes made when you have changed some settings".I really didn't get this. Since I made no changes to my .csproj file as of now then against what else shall I compare it after opening it in notepad. – user2913184 May 02 '15 at 15:20
  • When you make changes to your packaging settings, they are stored in the project file. Almost every setting in the property pages are stored in the project file. – jessehouwing May 02 '15 at 15:23
  • If I'm following you right then does it mean that when I will run the command you suggested me it will create a new xml element in the .csproj xml file (and I could see it in.csproj file after the web deploy package is created) – user2913184 May 02 '15 at 15:26
  • What I mean is that when you want to know what settings to pass to the team commandline, you can learn by comparing the project file before and after you change that setting through Visual Studio. – jessehouwing May 02 '15 at 15:29
  • Probably I got you now, that means lets say I create a web deploy package using "only files needed to run this application" option from VS then I can see this setting in .csproj file versus a different setting when I choose option "All files in this project folder" . Is that right? – user2913184 May 02 '15 at 15:34
  • Yes, that's what I meant. Those properties can then also be overridden from the commandline using the /d: – jessehouwing May 02 '15 at 15:36
  • Today I'm trying to use the command lines provided by you but I'm getting MSBUILD : error MSB1001: Unknown switch. Switch: /d:FilesToIncludeForPublish=AllFilesInProjectFolder error. Not sure why. Looked into msbuild help as well but didn't get any valuable info regarding this error. – user2913184 May 05 '15 at 16:38
  • this how I tried C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319>msbuild C:\Development\Works\HisServices\MyServices\MyServices\MySer vices.csproj /t:package /d:FilesToIncludeForPublish=AllFilesInProjectFolder /p:Configuration=Release and got the switch error. – user2913184 May 05 '15 at 16:41