Domanda

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:

  • Runner type: MSBuild
  • MSBuildVersion: 4.0
  • MSBuild ToolsVersion: 4.0
  • Run platform: x64
  • Targets: Build;Publish
  • Command Line Parameters: /p:Configuration=Staging;PackageLocation="C:\Sites\temp_publish\project\prod\project.zip"

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top