Skip to content

Commit

Permalink
Add explanation for Builder class in example (#15)
Browse files Browse the repository at this point in the history
* Add explanation for Builder class in example

When implementing MSBuildLocator I originally called `MSBuildLocator.RegisterInstance()`, then later in the same function I called other Microsoft.Build functions. 

This is my first large project with a major C# component. I didn't know that all of the dll imports in my function would be loaded when the function was entered, instead of when the import procedures were called.

This request adds a short description above the Builder class to explain why it's necessary--so that the MSBuildLocator dll loads first, then after the appropriate setup is requested and the `Builder` class is instantiated can more Microsoft.Build dlls be loaded properly.

* Update Builder class comment based on feedback
  • Loading branch information
nopppers authored and AndyGerlicher committed Apr 5, 2018
1 parent 33b6508 commit 6b85603
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion samples/BuilderApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ private static void Usage()
}
}

/// <summary>
/// Class for performing the project build
/// </summary>
/// <remarks>
/// The Microsoft.Build namespaces must be referenced from a method that is called
/// after RegisterInstance so that it has a chance to change their load behavior.
/// Here, we put Microsoft.Build calls into a separate class
/// that is only referenced after calling RegisterInstance.
/// </remarks>
public class Builder
{
public bool Build(string projectFile)
Expand Down Expand Up @@ -133,4 +142,4 @@ public void Shutdown()
public string Parameters { get; set; }
}
}
}
}

0 comments on commit 6b85603

Please sign in to comment.