From 62555c113f3e78853d64a827b1bab3626a885a74 Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Thu, 19 Dec 2019 14:41:13 -0800 Subject: [PATCH 1/6] unblock mixed reality toolkit dependencies related to asset retargetting --- .../Scripts/AssetScriptReferenceRetargeter.cs | 7 ++++--- .../ProjectGenerator/Scripts/MSBuildTools.cs | 16 +++++++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/AssetScriptReferenceRetargeter.cs b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/AssetScriptReferenceRetargeter.cs index ef0b3f8..4acdebc 100644 --- a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/AssetScriptReferenceRetargeter.cs +++ b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/AssetScriptReferenceRetargeter.cs @@ -336,7 +336,8 @@ private static Dictionary ProcessCompiledDLLs(strin foreach (Assembly dll in dlls) { - if (dll.name.Contains("MixedReality")) + // TODO - this should be improved/it won't work for non microsoft dlls + if (dll.name.Contains("Microsoft.MixedReality")) { string dllPath = Utilities.GetFullPathFromAssetsRelative($"Assets/../MSBuild/Publish/InEditor/WindowsStandalone32/{dll.name}.dll"); File.Copy(dllPath, Path.Combine(tmpDirPath, $"{dll.name}.dll"), true); @@ -374,9 +375,9 @@ private static Dictionary ProcessCompiledDLLs(strin { Debug.LogError($"Encountered a MonoScript we get a null Type from: '{monoScript.name}'"); } - else if (type.Namespace == null || !type.Namespace.Contains("Microsoft.MixedReality.Toolkit")) + else if (type.Namespace == null || !type.Namespace.Contains("Microsoft.MixedReality")) { - throw new InvalidDataException($"Type {type.Name} is not a member of the Microsoft.MixedReality.Toolkit namespace"); + throw new InvalidDataException($"Type {type.Name} is not a member of the Microsoft.MixedReality namespace"); } else { diff --git a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/MSBuildTools.cs b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/MSBuildTools.cs index 2902ef6..441af68 100644 --- a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/MSBuildTools.cs +++ b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/MSBuildTools.cs @@ -62,10 +62,10 @@ private class BuildTargetChanged : IActiveBuildTargetChanged public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget newTarget) { - if (EditorAnalyticsSessionInfo.elapsedTime > 0) - { - RefreshGeneratedOutput(forceGenerateEverything: Config.AutoGenerateEnabled); - } + // if (EditorAnalyticsSessionInfo.elapsedTime > 0) + // { + // RefreshGeneratedOutput(forceGenerateEverything: Config.AutoGenerateEnabled); + // } } } @@ -135,6 +135,12 @@ public static void GenerateSDKProjects() } } + public static void RegenerateSDKProjects() + { + RegenerateEverything(reparseUnityData:true); + Debug.Log($"{nameof(RegenerateSDKProjects)} Completed Succesfully."); + } + static MSBuildTools() { if (EditorAnalyticsSessionInfo.elapsedTime == 0) @@ -170,7 +176,7 @@ private static void RefreshGeneratedOutput(bool forceGenerateEverything) bool shouldClean = EditorPrefs.GetInt($"{nameof(MSBuildTools)}.{nameof(currentBuildTarget)}") != (int)currentBuildTarget || EditorPrefs.GetInt($"{nameof(MSBuildTools)}.{nameof(targetFramework)}") != (int)targetFramework || forceGenerateEverything; - + if (shouldClean) { // We clean up previous build if the EditorPrefs currentBuildTarget or targetFramework is different from current ones. From fa45f7d99d56cad50323d0b7a462af90795fa67f Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Fri, 20 Dec 2019 15:02:01 -0800 Subject: [PATCH 2/6] make items more generic and fix player excluded editor files --- .../MSBuildTemplates/SDKProjectTemplate.g.props.template | 7 ++++++- .../Scripts/AssetScriptReferenceRetargeter.cs | 8 ++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/MSBuildTemplates/SDKProjectTemplate.g.props.template b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/MSBuildTemplates/SDKProjectTemplate.g.props.template index 35b612f..c483e06 100644 --- a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/MSBuildTemplates/SDKProjectTemplate.g.props.template +++ b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/MSBuildTemplates/SDKProjectTemplate.g.props.template @@ -130,7 +130,12 @@ - + + diff --git a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/AssetScriptReferenceRetargeter.cs b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/AssetScriptReferenceRetargeter.cs index 4acdebc..98b64c3 100644 --- a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/AssetScriptReferenceRetargeter.cs +++ b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/AssetScriptReferenceRetargeter.cs @@ -375,10 +375,6 @@ private static Dictionary ProcessCompiledDLLs(strin { Debug.LogError($"Encountered a MonoScript we get a null Type from: '{monoScript.name}'"); } - else if (type.Namespace == null || !type.Namespace.Contains("Microsoft.MixedReality")) - { - throw new InvalidDataException($"Type {type.Name} is not a member of the Microsoft.MixedReality namespace"); - } else { assemblyInformation.CompiledClasses.Add(type.FullName, new ClassInformation() { Name = type.Name, Namespace = type.Namespace, FileId = fileId, Guid = newDllGuid }); @@ -424,8 +420,8 @@ private static void CopyPluginContents(string outputPath) } Directory.CreateDirectory(pluginPath); - CopyFiles(directory, pluginPath, "Microsoft.MixedReality.Toolkit*.dll"); - CopyFiles(directory, pluginPath, "Microsoft.MixedReality.Toolkit*.pdb"); + CopyFiles(directory, pluginPath, "Microsoft.MixedReality*.dll"); + CopyFiles(directory, pluginPath, "Microsoft.MixedReality*.pdb"); } } From c0a80d548f76ecb4601e88d001164797850f3d74 Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Fri, 20 Dec 2019 15:03:26 -0800 Subject: [PATCH 3/6] add back code --- .../Editor/ProjectGenerator/Scripts/MSBuildTools.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/MSBuildTools.cs b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/MSBuildTools.cs index 441af68..4ba0314 100644 --- a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/MSBuildTools.cs +++ b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/MSBuildTools.cs @@ -62,10 +62,10 @@ private class BuildTargetChanged : IActiveBuildTargetChanged public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget newTarget) { - // if (EditorAnalyticsSessionInfo.elapsedTime > 0) - // { - // RefreshGeneratedOutput(forceGenerateEverything: Config.AutoGenerateEnabled); - // } + if (EditorAnalyticsSessionInfo.elapsedTime > 0) + { + RefreshGeneratedOutput(forceGenerateEverything: Config.AutoGenerateEnabled); + } } } From 7b9b7d109ba69c1ce660f492593ad4cf3d20bf52 Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Fri, 20 Dec 2019 15:56:19 -0800 Subject: [PATCH 4/6] fix dll include --- .../Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs index 089ec05..2c666fa 100644 --- a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs +++ b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs @@ -95,7 +95,7 @@ public void RefreshPlugins() } } - RefreshProjects(); + //RefreshProjects(); } public void RefreshProjects() @@ -260,11 +260,13 @@ private CSProjectInfo GetProjectInfo(Dictionary projectsM if (!assemblyDefinitionInfo.BuiltInPackage) { - Uri dependencies = new Uri(Path.Combine(Utilities.AssetPath, "Dependencies")); + Uri dependencies = new Uri(Path.Combine(Utilities.AssetPath, "Dependencies\\")); foreach (PluginAssemblyInfo plugin in Plugins.Where(t => t.Type != PluginType.Native)) { + Debug.Log($"Plugin: {plugin.Name} {plugin.Type} {plugin.AutoReferenced} {plugin.ReferencePath}"); if (!dependencies.IsBaseOf(plugin.ReferencePath) && (plugin.AutoReferenced || assemblyDefinitionInfo.PrecompiledAssemblyReferences.Contains(plugin.Name))) { + Debug.Log($"Plugin referenced: {plugin.Name}"); toReturn.AddDependency(plugin); } } From 9f4e9f995fde6408342df4fd986d43e4b688088f Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Thu, 2 Jan 2020 12:15:28 -0800 Subject: [PATCH 5/6] fix some review comments --- .../MSBuildTemplates/SDKProjectTemplate.g.props.template | 7 +------ .../Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/MSBuildTemplates/SDKProjectTemplate.g.props.template b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/MSBuildTemplates/SDKProjectTemplate.g.props.template index c483e06..35b612f 100644 --- a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/MSBuildTemplates/SDKProjectTemplate.g.props.template +++ b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/MSBuildTemplates/SDKProjectTemplate.g.props.template @@ -130,12 +130,7 @@ - - + diff --git a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs index 2c666fa..a24760a 100644 --- a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs +++ b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs @@ -95,7 +95,7 @@ public void RefreshPlugins() } } - //RefreshProjects(); + RefreshProjects(); } public void RefreshProjects() From 09ad0bde846009cca8694ddfe720e66cf2a14485 Mon Sep 17 00:00:00 2001 From: Chris Barth Date: Tue, 7 Jan 2020 11:58:15 -0800 Subject: [PATCH 6/6] Update UnityProjectInfo.cs --- .../Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs index 956974d..345bd1f 100644 --- a/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs +++ b/Source/MSBuildTools.Unity/Packages/com.microsoft.msbuildforunity/Editor/ProjectGenerator/Scripts/UnityProjectInfo.cs @@ -265,10 +265,8 @@ private CSProjectInfo GetProjectInfo(Dictionary projectsM Uri dependencies = new Uri(Path.Combine(Utilities.AssetPath, "Dependencies\\")); foreach (PluginAssemblyInfo plugin in Plugins.Where(t => t.Type != PluginType.Native)) { - Debug.Log($"Plugin: {plugin.Name} {plugin.Type} {plugin.AutoReferenced} {plugin.ReferencePath}"); if (!dependencies.IsBaseOf(plugin.ReferencePath) && (plugin.AutoReferenced || assemblyDefinitionInfo.PrecompiledAssemblyReferences.Contains(plugin.Name))) { - Debug.Log($"Plugin referenced: {plugin.Name}"); toReturn.AddDependency(plugin); } } @@ -345,4 +343,4 @@ private List ScanForPluginDLLs() } } } -#endif \ No newline at end of file +#endif