0

In my Solution, I have three executables which two of them should not be distributed through ClickOnce and not have those files generated. They are internal console applications that are distributed to specific ends. The third is a normal ClickOnce Application distributed to my final users.

Following this question and this tip on a blog, I managed to remove the ClickOnce from those apps and build correctly from Visual Studio.

But a problem happens in my Continous Integration, performed with MSBuild Command Line. In the final steps of publishing, MSBuild throws errors because it didn't found the other two executable's manifests, so my Build fails. Also, when I check the publish output, it created folders in "Application Files" for those two applications containing the ".exe" and ".config" files (which is also undesired, since they will be automatically uploaded and they shouldn't be).

Is there a parameter or another way to make MSBuild ignore just the publishing step of those projects without Clickonce?

Thanks.

Community
  • 1
  • 1
Rafael Simonelli
  • 304
  • 4
  • 22

2 Answers2

0

you can use a custom target to achieve it. edit your project(csproj) file (right click project node -> unload project -> edit xxx.csproj) and add the following code on it.

<PropertyGroup>
    <!-- the folder of the project to build -->
    <ProjLocation>D:\Project\Msbuild\ConsoleApplication3\ConsoleApplication1</ProjLocation>
    <ProjLocationDebugDir>$(ProjLocation)\bin\Debug</ProjLocationDebugDir>
    <ProjPublishLocation>$(ProjLocationDebugDir)\app.publish</ProjPublishLocation>
    <!-- This is the web-folder, which provides the artefacts for click-once. After this
         build the project is actually deployed on the server -->
    <DeploymentFolder>D:\server\releases\</DeploymentFolder>
  </PropertyGroup>
  <Target Name="Test" DependsOnTargets="Clean">
    <Message Text="Publish-Build started for build no $(ApplicationRevision)" />  
    <MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj"
        Properties="$(DefaultBuildProperties)"
        Targets="Publish"/>
    <ItemGroup>
      <SetupFiles Include="$(ProjPublishLocation)\*.*"/>
      <UpdateFiles Include="$(ProjPublishLocation)\Application Files\**\*.*"/>
    </ItemGroup>
    <Copy SourceFiles="@(SetupFiles)" DestinationFolder="$(DeploymentFolder)\" />
    <Copy SourceFiles="@(UpdateFiles)" DestinationFolder="$(DeploymentFolder)\Application Files\%(RecursiveDir)"/>
  </Target>

  <Target Name="Clean">
    <Message Text="Clean project" />
    <MSBuild Projects="$(ProjLocation)\$(ProjectName).csproj"
    Properties="$(DefaultBuildProperties)"
    Targets="Clean"/>
  </Target>

Then, you can use the following msbuild command line.

msbuild /t:test

Here is a demo for your reference, please check the project named consoleapplication1 https://1drv.ms/u/s!AlvaNEnglADDgQRMB1LK4mo9KVXO

Zhanglong Wu - MSFT
  • 1,652
  • 1
  • 7
  • 8
  • I've been trying with a new Active Solution configuration in Configuration Manager and it seems to work. Is this the same path to Configuration Manager? – Rafael Simonelli Jan 23 '17 at 12:44
  • I'm glad to know that you resolve the issue, please post your solution and mark it answer, it will be beneficial to other communities who have the same issue. the solution I provide is a custom task which need to edit csproj file. – Zhanglong Wu - MSFT Jan 24 '17 at 08:48
0

I solved my problem by going in "BUILD" -> "CONFIGURATION MANAGER" and remove the other executables from actual configurations. Then created new configurations to build the other executables when needed in my solution.

My CI tasks where altered to set the Configuration property for each project, like this:

PROJECT A -> "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /target:clean;build;publish /property:Configuration=ProjectA_Release;"

PROJECT B -> "C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /target:clean;build;publish /property:Configuration=ProjectB_Release;"

And so on...

That way I could separate the files to publish and not get wrong stuff mixed in a single build.

Rafael Simonelli
  • 304
  • 4
  • 22