开发者

msbuild/clickonce publish files generated during the build

As a part of my build process I generate some files that should be included when creating a clickonce deployment.

Here is a blog post of someone telling you how to include items that's not part of the project. However, as someone mentions in the comments of that blogpost, it won't update the deploymentmanifest when you do it in the "BeforePublish" task and the files won't get downloaded - it works fine if you do it in the "BeforeBuild" tas开发者_如何学运维k though.

This gives me a chicken and egg problem as I have to perform the build first to generate the files I want included..

Does anyone have a solution for this ?

(p.s. at the moment generating the clickonce deployment using mage.exe is not an option, it have to be done using the Publish target)


Check out this post. I'm pretty sure that's the one I used when I setup our deployment process here.

We need to include non .net dlls in the bin directory for our app to work, they're already built so I don't have your problem of 'need to build first'. However I do the 'include' as part of the BeforePublish target:

   <Target Name="BeforePublish" DependsOnTargets="IncludeAdditionalPublishFiles; 
        ReleaseModeUpdateConfig;
        ReleaseModeInsertDatabaseRecords " />

  <ItemGroup>
    <AdditionalPublishFile Include="..\..\..\..\..\SharedDependencies\Leadtools\Leadtools.Codecs.J2k.dll">
      <Visible>False</Visible>
    </AdditionalPublishFile>
  </ItemGroup>


<Target Name="IncludeAdditionalPublishFiles" Condition=" '$(Configuration)' == 'Release' And Exists('@(IntermediateAssembly)') " >
    <Touch Files="@(IntermediateAssembly)" />
    <CreateItem Include="@(AdditionalPublishFile)" AdditionalMetadata="TargetPath=%(FileName)%(Extension);IsDataFile=false">
      <Output TaskParameter="Include" ItemName="_DeploymentManifestFiles" />
    </CreateItem>
  </Target>

As you can see, IncludeAdditionalPublishFiles does the 'include' work (check the blog post for a 'what the hells going on here'), I also update the config and set some values in an SQL Compact Db.

It takes a bit of trial and error to get it right but works in the end. Note you can add as many AdditionalPublishFile as you want.


You can do something like this:

<ItemGroup Condition="'$(Configuration)' == 'Release'">
    <Content Include="..\bin\Release\Reports\Report.srf" Condition="Exists('..\bin\Release\Reports\Reports.srf')">
      <Link>Reports\Reports.srf</Link>
      <Visible>false</Visible>
    </Content>
</ItemGroup>

This will require that you run the build and publish in 2 steps. That is, from a clean working copy, msbuild /p:Configuration=Release /t:Publish will not include this file in the deployment, you'll have to first run msbuild /p:Configuration=Release and then msbuild /p:Configuration=Release /t:Publish , the manifest will get updated during the Publish.


So you want to include files which are generated by a build.

I think, although you said that it's not an option, that the only solution is to perform a manual deployment via Mage or MageUI. Only that way you're in control between the build and the deployment. Can't you create a batch file to deploy your application? You can execute the batch file in the Post-Build event.


Try this: Build your project. Then go into the Application Files dialog and click "show all files". Does it show the files you want to include? If so, mark them as include(required). It should keep those, and include them in the deployment.

RobinDotNet

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜