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

Ask A Question

Stats

  • Questions 537k
  • Answers 537k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer SELECT CASE WHEN @yourDateTime BETWEEN '19000101 00:00:00.000' AND '20790606 23:59:29.997'… May 17, 2026 at 1:47 am
  • Editorial Team
    Editorial Team added an answer drupal_parse_info_file() is the closest function, but it takes a file… May 17, 2026 at 1:47 am
  • Editorial Team
    Editorial Team added an answer I believe the general method for doing this is to… May 17, 2026 at 1:47 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

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.