简体   繁体   中英

TFS publish csproj after build

I am developing a VSTO Addin, which we publish to network share via the csproj settings dialog below.

在此处输入图片说明

For instance, to publish we just click 'Publish Now' and it creates an installer for the VSTO addin (how? Seems to be automagic) and transfers to a network share.

Ok, great so far. So my question is, how to invoke this publish action via the TFS build configuration? So far I have seen that you can publish via MSBuild, but what about TFS (auto publish on successful build)?

Create a custom build and create your own msbuild project file.

But once you successfully publish, you will have a problem to manage publish number that is incremented by VisualStudio and that you will be obliged to do yourself. And After you will have the problem to checkin this change into TFS....

Some Help :

  <Target Name="Publish" >
    <MSBuild Projects="$(ProjectFile)" Targets="Publish" BuildInParallel="true" Properties="Configuration=Release;ImportProjectFile=true;PublishDir=..\$(LocalPublishFolder)\;PublishUrl=$(PublishFolder);InstallUrl=$(PublishFolder);UpdateUrl=$(PublishFolder)" > <!--ApplicationVersion=$(ApplicationVersion);-->
      <Output ItemName="ProjectOutputs" TaskParameter="TargetOutputs"/>
    </MSBuild>
    <UpdateApplicationRevision ProjectFilePath="$(Project2Publish)" />
    <ItemGroup>
      <_CopyItems Include="$(LocalPublishFolder)\**\*.*" />
    </ItemGroup>
    <Copy SourceFiles="@(_CopyItems)" DestinationFiles="@(_CopyItems->'$(PublishFolder)\%(RecursiveDir)%(Filename)%(Extension)')" />
    <RemoveDir Directories="$(LocalPublishFolder)" />
  </Target>


<UsingTask TaskName="UpdateApplicationRevision" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
   <ParameterGroup>
        <ProjectFilePath ParameterType="System.String" Required="true" />
    </ParameterGroup>
        <Task>
          <Reference Include="$(MSBuildToolsPath)\Microsoft.Build.dll" />
          <Reference Include="System.Xml" />
        <Code Type="Fragment" Language="cs">
            <![CDATA[
      var project = new Microsoft.Build.Evaluation.Project(ProjectFilePath);
      var property = project.GetProperty("ApplicationRevision");
      property.UnevaluatedValue = "" + (System.Int32.Parse(property.EvaluatedValue) + 1);
      project.Save();
]]>
        </Code>
    </Task>
</UsingTask>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM