Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4034230
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:56:46+00:00 2026-05-20T11:56:46+00:00

Is there a generic way I can get a post-build event to copy the

  • 0

Is there a generic way I can get a post-build event to copy the built assembly, and any .config and any .xml comments files to a folder (usually solution relative) without having to write a post-build event on each project in a solution?

The goal is to have a folder that contains the last successful build of an entire solution.

It would be nice to use the same build solution over multiple solutions too, possibly enabling/ disabling certain projects (so don’t copy unit tests etc).

Thanks,
Kieron

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:56:46+00:00Added an answer on May 20, 2026 at 11:56 am

    You can set common OutputPath to build all projects in Sln in one temp dir and copy required files to the latest build folder. In copy action you can set a filter to copy all dlls without “test” in its name.

    msbuild.exe 1.sln /p:Configuration=Release;Platform=AnyCPU;OutputPath=..\latest-temp
    

    There exists more complicated and more flexible solution. You can setup a hook for build process using CustomAfterMicrosoftCommonTargets. See this post for example.
    Sample targets file can be like that:

     <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
       <PropertyGroup>
         <BuildDependsOn>
           $(BuildDependsOn);
           PublishToLatest
         </BuildDependsOn>
       </PropertyGroup>
    
       <Target Name="PreparePublishingToLatest">
         <PropertyGroup>
           <TargetAssembly>$(TargetPath)</TargetAssembly>
           <TargetAssemblyPdb>$(TargetDir)$(TargetName).pdb</TargetAssemblyPdb>
           <TargetAssemblyXml>$(TargetDir)$(TargetName).xml</TargetAssemblyXml>
           <TargetAssemblyConfig>$(TargetDir)$(TargetName).config</TargetAssemblyConfig>
           <TargetAssemblyManifest>$(TargetDir)$(TargetName).manifest</TargetAssemblyManifest>
           <IsTestAssembly>$(TargetName.ToUpper().Contains("TEST"))</IsTestAssembly>
         </PropertyGroup>
         <ItemGroup>
           <PublishToLatestFiles Include="$(TargetAssembly)" Condition="Exists('$(TargetAssembly)')" />
           <PublishToLatestFiles Include="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" />
           <PublishToLatestFiles Include="$(TargetAssemblyXml)" Condition="Exists('$(TargetAssemblyXml)')" />
           <PublishToLatestFiles Include="$(TargetAssemblyConfig)" Condition="Exists('$(TargetAssemblyConfig)')" />
           <PublishToLatestFiles Include="$(TargetAssemblyManifest)" Condition="Exists('$(TargetAssemblyManifest)')" />
         </ItemGroup>   
       </Target>
    
       <Target Name="PublishToLatest" 
               Condition="Exists('$(LatestDir)') AND '$(IsTestAssembly)' == 'False' AND  '@(PublishToLatestFiles)' != ''" 
               DependsOnTargets="PreparePublishingToLatest">
    
         <Copy SourceFiles="@(PublishToLatestFiles)" DestinationFolder="$(LatestDir)" SkipUnchangedFiles="true" />
       </Target>
     </Project>
    

    In that targets file you can specify any actions you want.

    You can place it here “C:\Program Files\MSBuild\v4.0\Custom.After.Microsoft.Common.targets” or here “C:\Program Files\MSBuild\4.0\Microsoft.Common.targets\ImportAfter\PublishToLatest.targets”.

    And third variant is to add to every project you want to publish import of custom targets. See How to: Use the Same Target in Multiple Project Files

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There must be a generic way to transform some hierachical XML such as: <element1
Is there any way to determine if an object is a generic list? I'm
Is there any shorthand way of defining and using generic definitions without having to
Is there a generic way, without creating and managing your own CLR host, to
Is there a generic way to clone objects in VBA? So that i could
Is there a way to bind a Generic List to a multicolumn listbox, yes
Is there a way to collect (e.g. in a List) multiple 'generic' objects that
Through reflection, is there some way for me to look at a generic List's
Is there any feasible way of using generics to create a Math library that
Is there a Generics Friendly way of using Collection.EMPTY_LIST in my Java Program. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.