Create an output folder for each project in your solution, like _PublishedWebsites for web applications.

27 Nov
2011

Creating a publish folder for web applications is easy, you don’t have to do anything for that, web application project template does it for you. When you working with solutions for more than one project you have deal with different deployable units/packages. I was working on a build script that we need to run in our continuous integration process. But creating separate packages for each project was painful is you want to do it manually, and I tried to understand how web application projects template works and came up with this solution.

CopyToPublishedApplications msbuild file inspired by Microsoft web application projects build process file “Microsoft.WebApplication.targets”.

It creates _PublishedApplications\yourappname folder in your output directory.

By using this msbuild file you don’t have to deal with seperation of files based on projects when you are building solutions with multiple projects.

msbuild file and sample project is located in my github account. please follow the link : https://github.com/hancengiz/misc/tree/master/CopyToPublishedApplications

 

Usage

  • You just need to add below import line at the bottom of the project file and execute msbuild.exe with the /p:CopyToPublishedApplications=true parameter.

<Import Project=”….\CopyToPublishedApplications.msbuild” />

  • Add CopyToPublishedApplications parameter to msbuild command line. default value of CopyToPublishedApplications is false.

msbuild yoursolutionfile.sln /p:OutputPath=C:\yourcioutputfolder /p:CopyToPublishedApplications=true

  • After you addd import line in your projects and run your build with msbuild command line tool as it’s shown above you will get an output like below:
  • You can find this sample project structure in sampleproject folder. check out the import lines in each .csproj file, and just run build.bat file.

dir output /s /b

\sampleproject\output\ClassLibrary1.dll

\sampleproject\output\ClassLibrary1.pdb

\sampleproject\output\WindowsFormsApplication1.exe

\sampleproject\output\WindowsFormsApplication1.exe.config

\sampleproject\output\WindowsFormsApplication1.pdb

\sampleproject\output\WindowsFormsApplication2.exe

\sampleproject\output\WindowsFormsApplication2.exe.config

\sampleproject\output\WindowsFormsApplication2.pdb

\sampleproject\output\ _PublishedApplications

\sampleproject\output\ _PublishedApplications\ClassLibrary1

\sampleproject\output\ _PublishedApplications\WindowsFormsApplication1

\sampleproject\output\ _PublishedApplications\WindowsFormsApplication2

\sampleproject\output\ _PublishedApplications\ClassLibrary1\ClassLibrary1.dll

\sampleproject\output\ _PublishedApplications\ClassLibrary1\ClassLibrary1.pdb

\sampleproject\output\ _PublishedApplications\WindowsFormsApplication1\ClassLibrary1.dll

\sampleproject\output\ _PublishedApplications\WindowsFormsApplication1\ClassLibrary1.pdb

\sampleproject\output\ _PublishedApplications\WindowsFormsApplication1\WindowsFormsApplication1.exe

\sampleproject\output\ _PublishedApplications\WindowsFormsApplication1\WindowsFormsApplication1.exe.config

\sampleproject\output\ _PublishedApplications\WindowsFormsApplication1\WindowsFormsApplication1.pdb

\sampleproject\output\ _PublishedApplications\WindowsFormsApplication2\WindowsFormsApplication2.exe

\sampleproject\output\ _PublishedApplications\WindowsFormsApplication2\WindowsFormsApplication2.exe.config

\sampleproject\output\ _PublishedApplications\WindowsFormsApplication2\WindowsFormsApplication2.pdb



1 Response to Create an output folder for each project in your solution, like _PublishedWebsites for web applications.

Avatar

cengizhan2forum

January 15th, 2012 at 1:46 pm

güzel bir makale olmuş çok teşekkürler.

Comment Form

top