TeamCity: How tell MSBuild to take into account pu

2020-07-10 12:15发布

问题:

I have TeamCity build configuration with MSBuild step, when i would like to compile my project with publish profile. My publish profile is located in MyProject\Properties\PublishProfiles\profile.pubxml.

My profile.pubxml:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <PrecompileBeforePublish>True</PrecompileBeforePublish>
    <EnableUpdateable>True</EnableUpdateable>
    <DebugSymbols>False</DebugSymbols>
    <WDPMergeOption>MergeAllOutputsToASingleAssembly</WDPMergeOption>
    <UseMerge>True</UseMerge>
    <SingleAssemblyName>project</SingleAssemblyName>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <publishUrl>C:\DevelopmentFolder</publishUrl>
    <DeleteExistingFiles>True</DeleteExistingFiles>
  </PropertyGroup>
</Project>

My build step:

Runner type: MSBuild
Build file path: MyProject.csproj
MSBuild version: Microsoft Build Tools 2013
MSBuild ToolsVersion: 12
Run platform: x86

Now i would like to compile my project with account of parameters from my publish profile. I try to create all parameters as system parameters of build configuration (as in TeamCity says to use "Build Parameters" instead of "/property:" in an MSBuild step. What does that mean?), but i think MSBuild does not take into account parameters, because i can't see in bin directory project.dll file.

回答1:

Add TeamCity property system.PublishProfile and the value should be your pubxml profile name ("profile" in your example). Then add a build step which runs MSBuild with the target "WebPublish" - it works for me.