0

I have a C# big project in Visual Studio 2013 that is formed by:

  • 3 Web projects
  • 2 Windows Services project
  • 14 Dlls projects
  • 2 Test projects
  • 1 Database Project (.sqlproj)

As you can guess the final files are:

  • 3 Web Projects
  • 2 Windows Services
  • Database

I build it with msbuild.exe invoked from PowerShell.

$msbuild="C:\windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
$option0 = 'FOO.sln /t:Clean,Rebuild /p:Configuration=Debug /p:Outdir=$outputdir'
iex "$msbuild $option0" | tee C:\TFS\Oscar\Build\oscar.txt

The project builds and in the output folder I have a nice directory called _PublishedWebsites that contains the three websites, one in each directory. From here it wouldn't be complicated to deploy to servers using PowerShell.

In outputdir I have my FooDB.dacpac so I can easily use sqlpackage to deploy it to SQL Server.

My problem is with Windows Services. Instead of being in a folder they are in output folder, mixed with all DLLs, sqlproj files, test files.

Is there any way of having them in a folder similar to "_PublishedWebsites"?

I can copy all files to each windows service folder on deploy and will work... but feels wrong...

Oscar Foley
  • 6,817
  • 8
  • 57
  • 90

2 Answers2

1

YES! You can actually use MSDeploy which is the underlying technology for WebDeploy to create a similar deployment package for a Windows service or scheduled task.

The basic steps are

  • extend MSBuild to zip up the files into a package
  • add pre/post sync commands
  • create a deploy cmd to execute the package

https://dotnetcatch.com/2016/03/18/deploy-non-web-apps-with-msdeploy/

chief7
  • 14,263
  • 14
  • 47
  • 80
1

We've been using the nuget package PublishedApplications in in our Windows Service projects (which are actually just Console Apps using TopShelf ).

As a result, we get a nicely packaged app in the output folder {OutDir}/_PublishedApplications/{appName} (next to {OutDir}/PublishedWebSites) for those services.

I'm still looking for a way to get a similar behavior for *.sqlproj projects ...

tsimbalar
  • 5,790
  • 6
  • 37
  • 61
  • 1
    If you have a problem where all `Content` marked as `Copy Always` is copied to the root folder and not hierarchically see my answer to this [SO article](https://stackoverflow.com/questions/21732824/customise-build-build-output-for-specific-projects). – CrnaStena Mar 03 '17 at 18:39