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 982463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:42:01+00:00 2026-05-16T04:42:01+00:00

I’m developing a custom MSBuild task that builds an ORM layer , and using

  • 0

I’m developing a custom MSBuild task that builds an ORM layer, and using it in a project. I’m being hampered by Visual Studio’s behaviour of holding onto MSBuild task DLLs and not letting go.

I’d like to organize my solution like this;

My Solution
 |
 +- (1) ORM Layer Custom Task Project
 |  |
 |  +- BuildOrmLayerTask.cs     // here's my task
 |  
 +- (2) Business Logic Project  // and here's the project that uses it.
    |
    +- <UsingTask TaskName="BuildOrmLayerTask" AssemblyFile="$(TaskAssembly)" />

However, when project (2) builds, it locks onto the assembly from project (1). So now I can’t build project (1) again without closing the solution and re-opening it.

Is there any way I can organize things so that the custom build task is not kept locked by Visual Studio?

  • 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-16T04:42:02+00:00Added an answer on May 16, 2026 at 4:42 am

    (Edit: Sayed Ibrahim Hashimi, who literally wrote the book on msbuild, suggests the AppDomainIsolatedTask class for a better approach)

    I’ve managed to solve this one myself…

    Found this forum post from Dan Moseley, one of the MSBuild developers from Microsoft:

    Hi there,

    Unfortunately this is because MSBuild loads task assemblies in the
    primary appdomain. The CLR does not allow assemblies to unload
    from an appdomain as this allows important optimizations on their
    part.

    The only workarounds I suggest is to call out tomsbuild.exe to
    build the projects that use the task. To do this, create
    MSBuild.exe <> as an external tool in VS.

    Dan
    developer on msbuild
    DanMoseley – MSFT

    So, it seems that to stop the locks, you must spawn out a new MSBuild.exe process. It can’t be the one that runs inside Visual Studio, because when MSBuild runs, it loads the tasks into Visual Studio’s primary app domain, and that can never be unloaded.

    • create a new MSBuild project (a .csproj or similar) which overrides the ‘Build’ Target and performs your custom actions, eg;

      <!-- fragment of Prebuild.csproj -->   
      <Target Name="Build">   
           <BuildOrmLayerTask Repository="$(Repository)" />   
      </Target>
      
    • Add it to visual studio if you want, but use Configuration Manager to make sure it is notbuilt in any configuration. Just let VS take care of source control and suchlike, not building.

    • Edit the .csproj file of the project that depends on Prebuild.csproj. Add a BeforeBuild target which invokes MSBuild using the Exec task. This will start a new process, and when that process ends, the file locks are released. Example;

      <PropertyGroup>   
           <PrebuildProject>$(SolutionDir)Prebuild\Prebuild.csproj</PrebuildProject>   
      </PropertyGroup>   
      <Target Name="BeforeBuild">   
           <Exec Command="msbuild.exe &quot;$(PrebuildProject)&quot;" />   
      </Target>
      

    Now, when you build the dependent project, it executes MSBuild in a new process before running the compile.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

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.