8

I've read many articles on publishing from TeamCity using various versions of Visual Studio. I'm currently using v.9.1.7 of TeamCity and Visual Studio 2015.

I have my 3 build steps on check-in:

  • Clean & Rebuild
  • Unit Test
  • Publish

Build Steps

When I check in my files I get a Tests Passed success message:

Tests Passed

I can tell from here something isn't right as I'm expecting it to say something about publishing. When I look at the Build Log I see the following:

[12:48:22][API\API.sln] Publish [12:48:22][Publish] MSBuild [12:48:22][MSBuild] API\API\API.csproj: Build target: Publish [12:48:22][API\API\API.csproj] _DeploymentUnpublishable

My Publish Build Step is setup this way:

Publish Build Step

In my API project in Visual Studio I can publish to the correct location on the network. Here is my publish profile:

Visual Studio Publish Profile

I'm not sure what I'm missing. I'm expecting the Publishing build step to work like when I click the Build->Publish menu item in Visual Studio.

I'm guessing that I'm missing something or misunderstanding what the publishing build step is supposed to do.

Any help is appreciated.

webdad3
  • 8,893
  • 30
  • 121
  • 223
  • Not sure this will fix the problem, but the 'targets' field in your publish step should have the targets separated by a space or semicolon according to the comment e.g. `Rebuild;Publish` – Electric Sheep May 23 '16 at 14:41

5 Answers5

8

I was able to get it to work after days and days of searching. I found part of the answer here on Stack Overflow. The trick was to get it to work from the MSBuild Command Line:

C:\TFS\project\myProject\APIproject>msbuild apiproject.csproj /p:DeployOnBuild=true /p:PublishProfile="Properties\PublishProfiles\DEV.pubxml" /p:VisualStudioVersion=14.0

Once I got this running several times I was able to create a Build Step in Team City (see this question/answer) and I set the following:

  • Build file path: <location of the apiproject.csproj>
  • MSBuild version: Microsoft Build Tools 2015
  • MSBuild ToolsVersion: 14.0
  • Run platform: x86
  • Command Line Parameters: /p:DeployOnBuild=true /p:PublishProfile= "C:\TFS\API\API\Properties\PublishProfiles\DEV.pubxml" /p:VisualStudioVersion=14.0
Community
  • 1
  • 1
webdad3
  • 8,893
  • 30
  • 121
  • 223
1

IIRC, publishing from TeamCity requires certain files or alternatively VS installed on the build agent (which really isn't recommendable). Have you copied the necessary files to the build agent?

Hadi Hariri
  • 4,656
  • 2
  • 24
  • 13
  • What is IIRC? Right now everything is on my local machine. So technically I have VS where TC is. Once I get this all dialed in I do plan on moving it to it's own box. – webdad3 May 14 '16 at 13:54
1

Where are artifacts location defined. And you can use Tentacles for publishing build into various environments. I guess, you need to look towards artifacts configurations.

1

You can use MSBuild runner to Deploy your Application/API enter image description here

Add Command line parameter :

/t:Clean /p:DeployOnBuild=true /t:build /t:publish /p:PublishProfile=C:\_works\teamcity\publishprofiles\Publiush_Profile.pubxml /p:VisualStudioVersion=12.0

PublishPrfile URL should be your publish profile path.

This will work for you.

Community
  • 1
  • 1
Pramod Raut
  • 677
  • 3
  • 9
  • 22
0

VS will probably find your publish profile with just the name, like: /p:DeployOnBuild=true;/p:PublishProfile=DEV; very useful if you run more than one build agent.

And if you're deploying to an IIS you might need to add AllowUntrustedCertificate=true;

daniel
  • 1