Msbuild / clickonce publish files created during build

As part of my build process, I create some files that should be included when creating the clickonce deployment.

Here is a blog post on how to incorporate elements that are not part of the project. However, as someone mentions in the comments of this blogpost, he will not update the deployment manifest when you do this in the "BeforePublish" task and the files are not uploaded - everything will be fine if you do this in "BeforeBuild", the task.

This gives me a chicken and egg problem, since I need to complete the build first in order to generate the files I want to include.

Does anyone have a solution for this?

(ps currently generating a clickonce deployment using mage.exe is not an option, this must be done using the publish target)

+4
source share
4 answers

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 you to run the assembly and publish it in 2 steps. That is, from a clean working version of msbuild /p:Configuration=Release /t:Publish will not include this file in the deployment, you will first need to run msbuild /p:Configuration=Release , and then msbuild /p:Configuration=Release /t:Publish , the manifest will be updated at the time of publication.

+3
source

Mark this post . I am sure the one that I used when setting up our deployment process here.

We need to include non.net dll in the bin directory for our application in order to work, they are already built, so I do not have your "need to build again" problem. However, I am doing an "include" as part of the BeforePublish goal:

  <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 β€œenable” job (check the blog post for β€œwhat's happening here”), I also update the configuration and set some values ​​in SQL Compact Db.

It takes a little trial and error to fix this, but works in the end. Note that you can add as many additional documents as you want.

+2
source

So, you want to include the files that are generated by the assembly.

I think, although you said that this is not an option, the only solution is to do a manual deployment through Mage or MageUI. This is the only way you control assembly and deployment. Can you create a batch file to deploy your application? You can execute the batch file in the Post-Build event.

+1
source

Try the following: create your own project. Then go to the "Application files" dialog box and click "show all files." Does the file you want to include show? If so, mark them as included (required). He must keep them and include them in the deployment.

RobinDotNet

0
source

Source: https://habr.com/ru/post/1305004/


All Articles