Adding support for custom configurations (#20)
* Using _DEBUG and RuntimeLibrary to determine whether to copy debug CRT forwarders. Added an override flag to force it too. * Fix line feed * Handling C++ scenarios where projects can't be directly referenced and reducing properties used. * Update release notes * Adddressing PR feedback.
This commit is contained in:
Родитель
bebb0f24bc
Коммит
be5175b7c4
|
@ -4,34 +4,77 @@
|
|||
<PropertyGroup>
|
||||
<!-- Output folder for MSBuildForUnity -->
|
||||
<VCRTForwarders-PackageDestinationFolder>$(MSBuildThisFileName)</VCRTForwarders-PackageDestinationFolder>
|
||||
<VCRTForwarders-IncludeDebugCRT Condition="'$(VCRTForwarders-IncludeDebugCRT)$(Configuration)' == 'Debug'">true</VCRTForwarders-IncludeDebugCRT>
|
||||
<_VCRTForwarders-Platform>$(Platform)</_VCRTForwarders-Platform>
|
||||
<_VCRTForwarders-Platform Condition="'$(Platform)' == 'Win32'">x86</_VCRTForwarders-Platform>
|
||||
<_VCRTForwarders-SupportedPlatform Condition="'$(_VCRTForwarders-Platform)' == 'x86' Or '$(_VCRTForwarders-Platform)' == 'x64' Or '$(_VCRTForwarders-Platform)' == 'arm64'">true</_VCRTForwarders-SupportedPlatform>
|
||||
<ResolveReferencesDependsOn>
|
||||
$(ResolveReferencesDependsOn);ResolveVCRTForwarderReferences;
|
||||
</ResolveReferencesDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- x86 -->
|
||||
<ItemGroup Condition="'$(Configuration)' == 'Debug' And ('$(Platform)' == 'Win32' Or '$(Platform)' == 'x86')">
|
||||
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-x86\native\debug\*.dll" />
|
||||
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-x86\native\release\*.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Configuration)' == 'Release' And ('$(Platform)' == 'Win32' Or '$(Platform)' == 'x86')">
|
||||
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-x86\native\release\*.dll" />
|
||||
</ItemGroup>
|
||||
<UsingTask TaskName="UseDebugCRT" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
|
||||
<ParameterGroup>
|
||||
<ProjectFile ParameterType="System.String" Required="true" />
|
||||
<Configuration ParameterType="System.String" Required="true" />
|
||||
<Platform ParameterType="System.String" Required="true" />
|
||||
<TaskOutput ParameterType="System.Boolean" Output="true" />
|
||||
</ParameterGroup>
|
||||
<Task>
|
||||
<Reference Include="System.Xml"/>
|
||||
<Reference Include="Microsoft.Build"/>
|
||||
<Using Namespace="Microsoft.Build" />
|
||||
<Using Namespace="Microsoft.Build.Evaluation" />
|
||||
<Code Type="Fragment" Language="cs">
|
||||
<![CDATA[
|
||||
|
||||
<!-- x64 -->
|
||||
<ItemGroup Condition="'$(Configuration)' == 'Debug' And '$(Platform)' == 'x64'">
|
||||
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-x64\native\debug\*.dll" />
|
||||
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-x64\native\release\*.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Configuration)' == 'Release' And '$(Platform)' == 'x64'">
|
||||
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-x64\native\release\*.dll" />
|
||||
</ItemGroup>
|
||||
var properties = new Dictionary<string, string>
|
||||
{
|
||||
{ "Configuration", Configuration },
|
||||
{ "Platform", Platform }
|
||||
};
|
||||
|
||||
// Per MSDN, _DEBUG define can be checked to determine if debug CRT is in use.
|
||||
var collection = new ProjectCollection(properties);
|
||||
var project = collection.LoadProject(ProjectFile);
|
||||
ProjectMetadata def = project.AllEvaluatedItemDefinitionMetadata
|
||||
.LastOrDefault(p => p.ItemType == "ClCompile" && p.Name == "PreprocessorDefinitions");
|
||||
Boolean useDebug = def != null && (";" + def.EvaluatedValue + ";").Contains(";_DEBUG;");
|
||||
|
||||
<!-- arm64 -->
|
||||
<ItemGroup Condition="'$(Configuration)' == 'Debug' And '$(Platform)' == 'ARM64'">
|
||||
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-arm64\native\debug\*.dll" />
|
||||
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-arm64\native\release\*.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(Configuration)' == 'Release' And '$(Platform)' == 'ARM64'">
|
||||
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-arm64\native\release\*.dll" />
|
||||
</ItemGroup>
|
||||
// There seem to be cases where even if _DEBUG is not found, debug CRT is used based on RuntimeLibrary.
|
||||
if(!useDebug)
|
||||
{
|
||||
ProjectMetadata runtimeLibrary = project.AllEvaluatedItemDefinitionMetadata
|
||||
.LastOrDefault(p => p.ItemType == "ClCompile" && p.Name == "RuntimeLibrary");
|
||||
useDebug = runtimeLibrary != null && (String.Compare(runtimeLibrary.EvaluatedValue, "MultiThreadedDebugDLL", true) == 0 ||
|
||||
String.Compare(runtimeLibrary.EvaluatedValue, "MultiThreadedDebug", true) == 0);
|
||||
}
|
||||
|
||||
TaskOutput = useDebug;
|
||||
|
||||
]]>
|
||||
</Code>
|
||||
</Task>
|
||||
</UsingTask>
|
||||
|
||||
<Target Name="ResolveVCRTForwarderReferences">
|
||||
<UseDebugCRT ProjectFile="%(ProjectReferenceWithConfiguration.Identity)"
|
||||
Configuration="%(ProjectReferenceWithConfiguration.Configuration)"
|
||||
Platform="%(ProjectReferenceWithConfiguration.Platform)"
|
||||
Condition="'@(ProjectReferenceWithConfiguration)' != '' And '$(VCRTForwarders-IncludeDebugCRT)' == ''">
|
||||
<Output ItemName="TaskOutput" TaskParameter="TaskOutput"/>
|
||||
</UseDebugCRT>
|
||||
<PropertyGroup>
|
||||
<VCRTForwarders-IncludeDebugCRT Condition="'%(TaskOutput.Identity)' == 'true'">true</VCRTForwarders-IncludeDebugCRT>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition="$(VCRTForwarders-IncludeDebugCRT) == true And $(_VCRTForwarders-SupportedPlatform) == true">
|
||||
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(_VCRTForwarders-Platform)\native\debug\*.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="$(_VCRTForwarders-SupportedPlatform) == true">
|
||||
<ReferenceCopyLocalPaths Include="$(MSBuildThisFileDirectory)..\..\runtimes\win10-$(_VCRTForwarders-Platform)\native\release\*.dll" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
<!-- MSBuildForUnity support -->
|
||||
<ItemGroup Condition="'$(MSBuildForUnityVersion)' != ''">
|
||||
|
@ -44,8 +87,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<!--AnyCPU Not Supported -->
|
||||
<Target Name="BeforeBuild" Condition="'$(Platform)' == 'AnyCPU'" >
|
||||
<Warning Text=" Because your app is being built as AnyCPU no Microsoft.VCRTForwarders.140 DLLs were copied to your ouput folder. Microsoft.VCRTForwarders.140 only supports x86 or x64 applications due to a C++ Runtime dependency. Please change your app project architecture to x86 or x64 in the Configuration Manager."/>
|
||||
<Target Name="BeforeBuild" Condition="$(_VCRTForwarders-SupportedPlatform) != true" >
|
||||
<Warning Text=" Because your app is being built as $(Platform) no Microsoft.VCRTForwarders.140 DLLs were copied to your ouput folder. Microsoft.VCRTForwarders.140 only supports x86, x64, or arm64 applications due to a C++ Runtime dependency. Please change your app project architecture to x86, x64, or arm64 in the Configuration Manager."/>
|
||||
</Target>
|
||||
|
||||
</Project>
|
|
@ -2,7 +2,7 @@
|
|||
<package>
|
||||
<metadata>
|
||||
<id>Microsoft.VCRTForwarders.140</id>
|
||||
<version>1.0.5</version>
|
||||
<version>1.0.6</version>
|
||||
<title>VCRT 140 App-Local DLL Forwarders</title>
|
||||
<authors>Microsoft</authors>
|
||||
<owners>Microsoft</owners>
|
||||
|
@ -13,6 +13,9 @@
|
|||
<requireLicenseAcceptance>true</requireLicenseAcceptance>
|
||||
<description>App-local DLLs that forward to runtime components of Visual C++ libraries which are required to run Visual C++ applications. The runtime components being forwarded to should already be installed on a given machine, this can be done using the Visual C++ Redistributable Packages https://aka.ms/AA4pp63. See https://github.com/Microsoft/vcrt-forwarders for more details. </description>
|
||||
<releaseNotes>
|
||||
1.0.6
|
||||
Added support for custom configurations
|
||||
|
||||
1.0.5
|
||||
Added support for MSBuildForUnity
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче