@@ -201,23 +201,41 @@ public override bool Execute() {
201201 </Target >
202202
203203
204- <Target Name =" FindVCRuntime" Returns =" VCRuntimeDLL" >
205- <PropertyGroup Condition =" $(PlatformToolset) != 'v140'" >
206- <VCRedistDir >$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\</VCRedistDir >
207- <VCRedistDir Condition =" $(Platform) == 'Win32'" >$(VCRedistDir)x86\</VCRedistDir >
208- <VCRedistDir Condition =" $(Platform) != 'Win32'" >$(VCRedistDir)$(Platform)\</VCRedistDir >
209- </PropertyGroup >
204+ <Target Name =" FindVCRedistDir" >
205+ <!-- Hard coded path for VS 2015 -->
210206 <PropertyGroup Condition =" $(PlatformToolset) == 'v140'" >
211207 <VCRedistDir >$(VCInstallDir)\redist\</VCRedistDir >
208+ </PropertyGroup >
209+
210+ <!-- Search for version number in some broken Build Tools installs -->
211+ <ItemGroup Condition =" $(VCRedistDir) == '' and $(VCToolsRedistVersion) == ''" >
212+ <_RedistFiles Include =" $(VCInstallDir)\Redist\MSVC\*\*.*" />
213+ </ItemGroup >
214+ <PropertyGroup Condition =" $(VCRedistDir) == '' and $(VCToolsRedistVersion) == ''" >
215+ <_RedistDir >%(_RedistFiles.Directory)</_RedistDir >
216+ <VCToolsRedistVersion >$([System.IO.Path]::GetFileName($(_RedistDir.Trim(`\`))))</VCToolsRedistVersion >
217+ </PropertyGroup >
218+
219+ <!-- Use correct path for VS 2017 and later -->
220+ <PropertyGroup Condition =" $(VCRedistDir) == ''" >
221+ <VCRedistDir >$(VCInstallDir)\Redist\MSVC\$(VCToolsRedistVersion)\</VCRedistDir >
222+ </PropertyGroup >
223+
224+ <PropertyGroup >
212225 <VCRedistDir Condition =" $(Platform) == 'Win32'" >$(VCRedistDir)x86\</VCRedistDir >
213226 <VCRedistDir Condition =" $(Platform) != 'Win32'" >$(VCRedistDir)$(Platform)\</VCRedistDir >
214227 </PropertyGroup >
215228
229+ <Message Text =" VC Redist Directory: $(VCRedistDir)" />
230+ <Message Text =" VC Redist Version: $(VCToolsRedistVersion)" />
231+ </Target >
232+
233+ <Target Name =" FindVCRuntime" Returns =" VCRuntimeDLL" DependsOnTargets =" FindVCRedistDir" >
216234 <ItemGroup Condition =" $(VCInstallDir) != ''" >
217235 <VCRuntimeDLL Include =" $(VCRedistDir)\Microsoft.VC*.CRT\vcruntime*.dll" />
218236 </ItemGroup >
219237
220- <Warning Text =" vcruntime14 *.dll not found under $(VCInstallDir) " Condition =" @(VCRuntimeDLL) == ''" />
221- <Message Text =" VCRuntimeDLL: @(VCRuntimeDLL) " Importance = " high " />
238+ <Warning Text =" vcruntime *.dll not found under $(VCRedistDir). " Condition =" @(VCRuntimeDLL) == ''" />
239+ <Message Text =" VC Runtime DLL(s):%0A- @(VCRuntimeDLL,'%0A- ') " />
222240 </Target >
223241</Project >
0 commit comments