Additional IL2CPP vs. .NET and NET46 vs NETStandard20 fixes (+ other) (#27)
* This handles the case where dependency is given in form of 'GUID:{asset guid}' instead of project name, also fixes initially mistaken NETStandard and NET46 diff to be NET and IL2CPP diff. And also adds tests * Fixed a bug * Removed empty propertygroup. Removed empty propertygroup.
This commit is contained in:
Родитель
794a787f8c
Коммит
7a4c4e7b76
|
@ -1,7 +1,7 @@
|
|||
<Project>
|
||||
<PropertyGroup>
|
||||
<AssemblySearchPaths>$(AssemblySearchPaths);<!--PLATFORM_COMMON_ASSEMBLY_SEARCH_PATHS_TOKEN-->;C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5;$(UnityEditorInstallFolder)Data\PlaybackEngines\MetroSupport\Managed\UAP\</AssemblySearchPaths>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<TargetFramework><!--TARGET_FRAMEWORK_TOKEN--></TargetFramework>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<DefineConstants>$(DefineConstants);<!--PLATFORM_COMMON_DEFINE_CONSTANTS-->;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<TargetPlatformVersion><!--UWP_TARGET_PLATFORM_VERSION_TOKEN--></TargetPlatformVersion>
|
||||
|
@ -32,10 +32,6 @@
|
|||
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5\System.Runtime.WindowsRuntime.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
<Reference Include="WinRTLegacy" Condition="$(UnityMajorVersion) < 2019">
|
||||
<HintPath>$(UnityEditorInstallFolder)Data\PlaybackEngines\MetroSupport\Managed\UAP\WinRTLegacy.dll</HintPath>
|
||||
</Reference>
|
||||
|
||||
<Reference Include="Windows">
|
||||
<HintPath>C:\Program Files (x86)\Windows Kits\10\UnionMetadata\$(TargetPlatformVersion)\windows.winmd</HintPath>
|
||||
</Reference>
|
|
@ -51,4 +51,4 @@
|
|||
</Reference>
|
||||
<!--PLATFORM_COMMON_REFERENCE_TEMPLATE_END-->
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
|
@ -117,6 +117,11 @@ namespace Microsoft.Build.Unity.ProjectGeneration
|
|||
/// </summary>
|
||||
public TargetFramework TargetFramework { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scripting backend for this platform (Mono, .NET, IL2CPP)
|
||||
/// </summary>
|
||||
public ScriptingBackend ScriptingBackend { get; }
|
||||
|
||||
/// <summary>
|
||||
/// These defines are specific for this platform and common or player/editor.
|
||||
/// </summary>
|
||||
|
@ -156,6 +161,7 @@ namespace Microsoft.Build.Unity.ProjectGeneration
|
|||
BuildTargetGroup = Utilities.GetBuildTargetGroup(BuildTarget);
|
||||
|
||||
TargetFramework = BuildTargetGroup.GetTargetFramework();
|
||||
ScriptingBackend = BuildTargetGroup.GetScriptingBackend();
|
||||
|
||||
CommonPlatformDefines = commonPlatformDefines;
|
||||
AdditionalPlayerDefines = additionalPlayerDefines;
|
||||
|
|
|
@ -177,7 +177,7 @@ namespace Microsoft.Build.Unity.ProjectGeneration
|
|||
{
|
||||
string configuration = inEditorConfiguration ? "InEditor" : "Player";
|
||||
|
||||
string platformTemplate = File.ReadAllText(TemplateFiles.Instance.GetTemplateFilePathForPlatform(platform.Name, configuration, platform.TargetFramework.AsTemplateString()));
|
||||
string platformTemplate = File.ReadAllText(TemplateFiles.Instance.GetTemplateFilePathForPlatform(platform.Name, configuration, platform.ScriptingBackend));
|
||||
|
||||
string platformPropsText;
|
||||
if (inEditorConfiguration)
|
||||
|
|
|
@ -16,7 +16,14 @@ namespace Microsoft.Build.Unity.ProjectGeneration
|
|||
Net20,
|
||||
Net46
|
||||
}
|
||||
|
||||
|
||||
public enum ScriptingBackend
|
||||
{
|
||||
Mono,
|
||||
Net,
|
||||
IL2CPP
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper extensions for the <see cref="TargetFramework"/> enum.
|
||||
/// </summary>
|
||||
|
@ -91,6 +98,32 @@ namespace Microsoft.Build.Unity.ProjectGeneration
|
|||
|
||||
throw new PlatformNotSupportedException("ApiCompatibilityLevel platform not matched.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the configured <see cref="ScriptingBackend"/> for the <see cref="BuildTargetGroup"/>.
|
||||
/// </summary>
|
||||
/// <param name="this">The <see cref="BuildTargetGroup"/> to get <see cref="ScriptingBackend"/> for.</param>
|
||||
/// <returns>The <see cref="ScriptingBackend"/> configured for given <see cref="BuildTargetGroup"/>.</returns>
|
||||
public static ScriptingBackend GetScriptingBackend(this BuildTargetGroup @this)
|
||||
{
|
||||
if (@this == BuildTargetGroup.Unknown)
|
||||
{
|
||||
// This may be different on older unity versions
|
||||
return ScriptingBackend.Mono;
|
||||
}
|
||||
|
||||
switch (PlayerSettings.GetScriptingBackend(@this))
|
||||
{
|
||||
case ScriptingImplementation.Mono2x:
|
||||
return ScriptingBackend.Mono;
|
||||
case ScriptingImplementation.IL2CPP:
|
||||
return ScriptingBackend.IL2CPP;
|
||||
case ScriptingImplementation.WinRTDotNET:
|
||||
return ScriptingBackend.Net;
|
||||
}
|
||||
|
||||
throw new PlatformNotSupportedException("ScriptingBackend platform not matched.");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -147,9 +147,9 @@ namespace Microsoft.Build.Unity.ProjectGeneration
|
|||
/// <param name="platform">The platform of the requested template.</param>
|
||||
/// <param name="configuration">The configuration of the requested template.</param>
|
||||
/// <returns>The absolute file path for the platform template to use.</returns>
|
||||
public string GetTemplateFilePathForPlatform(string platform, string configuration, string apiLevel)
|
||||
public string GetTemplateFilePathForPlatform(string platform, string configuration, ScriptingBackend scriptingBackend)
|
||||
{
|
||||
if (PlatformTemplates.TryGetValue($"{platform}.{configuration}.{apiLevel}.props.template", out string templatePath)
|
||||
if (PlatformTemplates.TryGetValue($"{platform}.{configuration}.{scriptingBackend.ToString()}.props.template", out string templatePath)
|
||||
|| PlatformTemplates.TryGetValue($"{platform}.{configuration}.Any.props.template", out templatePath)
|
||||
|| PlatformTemplates.TryGetValue($"{platform}.Configuration.Any.props.template", out templatePath))
|
||||
{
|
||||
|
|
|
@ -145,6 +145,11 @@ namespace Microsoft.Build.Unity.ProjectGeneration
|
|||
|
||||
private CSProjectInfo GetProjectInfo(Dictionary<string, CSProjectInfo> projectsMap, Dictionary<string, AssemblyDefinitionInfo> asmDefInfoMap, HashSet<string> builtInPackagesWithoutSource, string projectKey, string projectOutputPath)
|
||||
{
|
||||
if (projectKey.StartsWith("GUID:"))
|
||||
{
|
||||
projectKey = Path.GetFileNameWithoutExtension(AssetDatabase.GUIDToAssetPath(projectKey.Substring("GUID:".Length)));
|
||||
}
|
||||
|
||||
if (projectsMap.TryGetValue(projectKey, out CSProjectInfo value))
|
||||
{
|
||||
return value;
|
||||
|
@ -152,7 +157,8 @@ namespace Microsoft.Build.Unity.ProjectGeneration
|
|||
|
||||
if (!asmDefInfoMap.TryGetValue(projectKey, out AssemblyDefinitionInfo assemblyDefinitionInfo))
|
||||
{
|
||||
throw new InvalidOperationException($"Can't find an asmdef for project: {projectKey}");
|
||||
Debug.LogError($"Can't find an asmdef for project: {projectKey}; Unity actually allows this, so proceeding.");
|
||||
return null;
|
||||
}
|
||||
|
||||
CSProjectInfo toReturn = new CSProjectInfo(this, assemblyDefinitionInfo, projectOutputPath);
|
||||
|
@ -183,7 +189,11 @@ namespace Microsoft.Build.Unity.ProjectGeneration
|
|||
continue;
|
||||
}
|
||||
|
||||
toReturn.AddDependency(GetProjectInfo(projectsMap, asmDefInfoMap, builtInPackagesWithoutSource, reference, projectOutputPath));
|
||||
CSProjectInfo dependencyToAdd = GetProjectInfo(projectsMap, asmDefInfoMap, builtInPackagesWithoutSource, reference, projectOutputPath);
|
||||
if (dependencyToAdd != null)
|
||||
{
|
||||
toReturn.AddDependency(dependencyToAdd);
|
||||
}
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License. See LICENSE in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
#if UNITY_WSA
|
||||
using System;
|
||||
#endif
|
||||
|
||||
namespace Microsoft.Build.Unity.ProjectGeneration.Test
|
||||
{
|
||||
[Serializable]
|
||||
public enum TestResult
|
||||
{
|
||||
Success,
|
||||
|
|
Загрузка…
Ссылка в новой задаче