@@ -15,6 +15,7 @@ namespace StyleCopTester
1515 using System . Threading ;
1616 using System . Threading . Tasks ;
1717 using System . Windows . Threading ;
18+ using Microsoft . Build . Locator ;
1819 using Microsoft . CodeAnalysis ;
1920 using Microsoft . CodeAnalysis . CodeActions ;
2021 using Microsoft . CodeAnalysis . CodeFixes ;
@@ -85,6 +86,8 @@ private static async Task MainAsync(string[] args, CancellationToken cancellatio
8586 }
8687 }
8788
89+ MSBuildLocator . RegisterDefaults ( ) ;
90+
8891 Stopwatch stopwatch = Stopwatch . StartNew ( ) ;
8992 var analyzers = GetAllAnalyzers ( ) ;
9093
@@ -96,9 +99,17 @@ private static async Task MainAsync(string[] args, CancellationToken cancellatio
9699 return ;
97100 }
98101
102+ var properties = new Dictionary < string , string >
103+ {
104+ // This property ensures that XAML files will be compiled in the current AppDomain
105+ // rather than a separate one. Any tasks isolated in AppDomains or tasks that create
106+ // AppDomains will likely not work due to https://github.com/Microsoft/MSBuildLocator/issues/16.
107+ { "AlwaysCompileMarkupFilesInSeparateDomain" , bool . FalseString } ,
108+ } ;
109+
99110 MSBuildWorkspace workspace = MSBuildWorkspace . Create ( ) ;
100111 string solutionPath = args . SingleOrDefault ( i => ! i . StartsWith ( "/" , StringComparison . Ordinal ) ) ;
101- Solution solution = await workspace . OpenSolutionAsync ( solutionPath , cancellationToken ) . ConfigureAwait ( false ) ;
112+ Solution solution = await workspace . OpenSolutionAsync ( solutionPath , cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
102113
103114 Console . WriteLine ( $ "Loaded solution in { stopwatch . ElapsedMilliseconds } ms") ;
104115
0 commit comments