GoldBishop
GoldBishop

Reputation: 2861

MSBuild does not deploy MVC Application in Build Task

Recently was given the task to load up a MVC project into TeamCity. With that being said, i learned that MVC Applications MUST BE Deployed, unlike most "Normal" web-applications.

All that being considered, i build the project Build Task just like any others, did some trouble shooing and ALOT of google'ing.

Here is what i ended up with:

I have read that i need to install Web Deployment Project for the server but we dont have Visual Studio installed on the server, only TeamCity 8.x.

Personally, i want to try and keep development software off the server, so that it is a true mock-up of what the client server will be like.

What other settings do i need to put in, or if i have to split the Build & Deploy into two seperate tasks, what should the 2nd task be?

Upvotes: 1

Views: 827

Answers (1)

GoldBishop
GoldBishop

Reputation: 2861

Took me awhile to get back to my originally posted question.

Final solution was to add this to the csproj file.

<Target Name="PublishToFileSystem" DependsOnTargets="PipelinePreDeployCopyAllFilesToOneFolder">
    <Error Condition="'$(PublishDestination)'==''" Text="The PublishDestination property must be set to the intended publishing destination." />
    <MakeDir Condition="!Exists($(PublishDestination))" Directories="$(PublishDirectories)" />
    <ItemGroup>
      <PublishFiles Include="$(_PackageTempDir)\**\*.*" />
    </ItemGroup>
    <Copy SourceFiles="@(PublishFiles)" DestinationFiles="@(PublishFiles->'$(PublishDestination)\%(RecursiveDir)%(Filename)%(Extension)')" SkipUnchangedFiles="true" />
</Target>

and then reference the Build Target: PublishToFileSystem

Parameters part of the MSBuild ended up looking like:

/p:Configuration=Release;PublishDestination=%WebSiteDirectory%

with %WebSiteDirectory% being the destination location for the website.

Upvotes: 3

Related Questions