File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 77 * of patent rights can be found in the PATENTS file in the same directory.
88 */
99
10+ using System . Diagnostics ;
1011using React . TinyIoC ;
1112
1213namespace React . MSBuild
@@ -23,6 +24,14 @@ public class AssemblyRegistration : IAssemblyRegistration
2324 /// <param name="container">Container to register components in</param>
2425 public void Register ( TinyIoCContainer container )
2526 {
27+ if ( ! MSBuildHost . IsInMSBuild ( ) )
28+ {
29+ Trace . WriteLine (
30+ "Warning: React.MSBuild AssemblyRegistration called, but not currently in MSBuild!"
31+ ) ;
32+ return ;
33+ }
34+
2635 container . Register < ICache , NullCache > ( ) ;
2736 container . Register < IFileSystem , SimpleFileSystem > ( ) ;
2837 }
Original file line number Diff line number Diff line change 88 */
99
1010using System ;
11+ using System . Diagnostics ;
1112
1213namespace React . MSBuild
1314{
@@ -41,5 +42,21 @@ private static bool Initialize()
4142
4243 return true ;
4344 }
45+
46+ /// <summary>
47+ /// Determines if the current process is MSBuild
48+ /// </summary>
49+ /// <returns><c>true</c> if we are currently in MSBuild</returns>
50+ public static bool IsInMSBuild ( )
51+ {
52+ try
53+ {
54+ return Process . GetCurrentProcess ( ) . ProcessName . StartsWith ( "MSBuild" ) ;
55+ }
56+ catch ( Exception )
57+ {
58+ return false ;
59+ }
60+ }
4461 }
4562}
You can’t perform that action at this time.
0 commit comments