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 7
7
* of patent rights can be found in the PATENTS file in the same directory.
8
8
*/
9
9
10
+ using System . Diagnostics ;
10
11
using React . TinyIoC ;
11
12
12
13
namespace React . MSBuild
@@ -23,6 +24,14 @@ public class AssemblyRegistration : IAssemblyRegistration
23
24
/// <param name="container">Container to register components in</param>
24
25
public void Register ( TinyIoCContainer container )
25
26
{
27
+ if ( ! MSBuildHost . IsInMSBuild ( ) )
28
+ {
29
+ Trace . WriteLine (
30
+ "Warning: React.MSBuild AssemblyRegistration called, but not currently in MSBuild!"
31
+ ) ;
32
+ return ;
33
+ }
34
+
26
35
container . Register < ICache , NullCache > ( ) ;
27
36
container . Register < IFileSystem , SimpleFileSystem > ( ) ;
28
37
}
Original file line number Diff line number Diff line change 8
8
*/
9
9
10
10
using System ;
11
+ using System . Diagnostics ;
11
12
12
13
namespace React . MSBuild
13
14
{
@@ -41,5 +42,21 @@ private static bool Initialize()
41
42
42
43
return true ;
43
44
}
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
+ }
44
61
}
45
62
}
You can’t perform that action at this time.
0 commit comments