Skip to content

Executing MSBuild task from inside of Visual Studio locks a DLL #4

Open
@rvukovic

Description

@rvukovic

If the .csproj is modified so that it calls Migrate task in the AfterBuild target the project DLL will stay locked after the first compile. The problem is that Assembly.LoadFrom locks the DLL and it can not be unloaded.

Solution for the problem is adding the attributes [LoadInSeparateAppDomain] and [Serializable] to the Migrator.MSBuild.Migrate class and inheriting from AppDomainIsolatedTask instead of the Task. TaskLogger has to be change accordingly.

[LoadInSeparateAppDomain]
[Serializable]
public class Migrate : AppDomainIsolatedTask 
{ 

 public class TaskLogger : ILogger
{
    private readonly AppDomainIsolatedTask _task;

    public TaskLogger(AppDomainIsolatedTask task)
           {
                   _task = task;
           }

Sorry for not using the GIT :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions