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

Is there a way to make this method generic so I can return a
There is any way to set the generic type (T) of class in the
Is there any way to store the generic parameter type passed in at construction
Let's imagine I have instantiated generic type by Activator.CreateInstance. Is there any way to
Is there any good way too get a indication if a computer is capable
Is there a generic API call I can make to get a handle of
Is there a generic way of determining all attributes (and their values) from an
Is there a way to declare that the variable type of a generic class
Is there a way in Boo to express some constaints on generic types as
I was wondering if there's a way I could code some kind of generic

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.