File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed
src/Cli/Microsoft.DotNet.Cli.Utils Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change 6
6
using System . Diagnostics ;
7
7
using System . IO ;
8
8
using System . Linq ;
9
- using System . Reflection ;
10
9
using System . Runtime . InteropServices ;
11
10
using System . Text ;
12
11
@@ -116,18 +115,14 @@ public int ExecuteInProc(string[] arguments)
116
115
Environment . SetEnvironmentVariable ( kvp . Key , kvp . Value ) ;
117
116
}
118
117
119
- Assembly assembly = Assembly . LoadFrom ( _msbuildPath ) ;
120
- Type type = assembly . GetType ( MSBuildAppClassName ) ;
121
- MethodInfo mi = type . GetMethod ( "Main" ) ;
122
-
123
118
try
124
119
{
125
- return ( int ) mi . Invoke ( null , new object [ ] { arguments } ) ;
120
+ return Microsoft . Build . CommandLine . MSBuildApp . Main ( arguments ) ;
126
121
}
127
- catch ( TargetInvocationException targetException )
122
+ catch ( Exception exception )
128
123
{
129
124
Console . Error . Write ( "Unhandled exception: " ) ;
130
- Console . Error . WriteLine ( targetException . InnerException . ToString ( ) ) ;
125
+ Console . Error . WriteLine ( exception . ToString ( ) ) ;
131
126
132
127
return unchecked ( ( int ) 0xe0434352 ) ; // EXCEPTION_COMPLUS
133
128
}
Original file line number Diff line number Diff line change 15
15
</ItemGroup >
16
16
17
17
<ItemGroup >
18
- <PackageReference Include =" Microsoft.Build.Runtime" Version =" $(MicrosoftBuildRuntimePackageVersion)" />
18
+ <PackageReference Include =" Microsoft.Build.Runtime" Version =" $(MicrosoftBuildRuntimePackageVersion)" GeneratePathProperty = " true " PrivateAssets = " all " />
19
19
<PackageReference Include =" Microsoft.Extensions.DependencyModel" Version =" $(MicrosoftExtensionsDependencyModelPackageVersion)" />
20
20
<PackageReference Include =" NuGet.Versioning" Version =" $(NuGetVersioningPackageVersion)" />
21
21
<PackageReference Include =" NuGet.Packaging" Version =" $(NuGetPackagingPackageVersion)" />
28
28
<PackageReference Include =" Microsoft.Build" Version =" $(MicrosoftBuildPackageVersion)" />
29
29
<PackageReference Include =" Microsoft.Build.Utilities.Core" Version =" $(MicrosoftBuildUtilitiesCorePackageVersion)" />
30
30
<PackageReference Include =" System.CommandLine" Version =" $(SystemCommandLineVersion)" />
31
+ <Reference Include =" $(PkgMicrosoft_Build_Runtime)\contentFiles\any\net5.0\ref\MSBuild.dll" Private =" True" />
31
32
</ItemGroup >
32
33
33
34
</Project >
You can’t perform that action at this time.
0 commit comments