Exemplo n.º 1
0
        protected static string GetPlatformAssemblyPath(WSASDK wsaSDK)
        {
            string text;
            string path;

            switch (wsaSDK)
            {
            case WSASDK.SDK80:
                text = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0", "InstallationFolder");
                path = "Windows Kits\\8.0";
                break;

            case WSASDK.SDK81:
                text = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1", "InstallationFolder");
                path = "Windows Kits\\8.1";
                break;

            case WSASDK.PhoneSDK81:
                text = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhoneApp\\v8.1", "InstallationFolder");
                path = "Windows Phone Kits\\8.1";
                break;

            default:
                throw new Exception("Unknown Windows SDK: " + wsaSDK.ToString());
            }
            if (text == null)
            {
                string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
                text = Path.Combine(folderPath, path);
            }
            return(Path.Combine(text, "References\\CommonConfiguration\\Neutral\\Windows.winmd"));
        }
Exemplo n.º 2
0
 public static AssemblyTypeInfoGenerator.ClassInfo[] ExtractAssemblyTypeInfo(BuildTarget targetPlatform, bool isEditor, string assemblyPathName, string[] searchDirs)
 {
     if (CSharpLanguage.GetUseMicrosoftCSharpCompiler(targetPlatform, isEditor, assemblyPathName))
     {
         WSASDK wSASDK = EditorUserBuildSettings.wsaSDK;
         if (wSASDK == WSASDK.UniversalSDK81)
         {
             wSASDK = WSASDK.SDK81;
         }
         string nETCoreFrameworkReferencesDirectory = MicrosoftCSharpCompiler.GetNETCoreFrameworkReferencesDirectory(wSASDK);
         searchDirs = new List <string>(searchDirs)
         {
             nETCoreFrameworkReferencesDirectory
         }.ToArray();
     }
     AssemblyTypeInfoGenerator.ClassInfo[] result;
     try
     {
         AssemblyTypeInfoGenerator assemblyTypeInfoGenerator = new AssemblyTypeInfoGenerator(assemblyPathName, searchDirs);
         result = assemblyTypeInfoGenerator.GatherClassInfo();
     }
     catch (Exception ex)
     {
         throw new Exception(string.Concat(new object[]
         {
             "ExtractAssemblyTypeInfo: Failed to process ",
             assemblyPathName,
             ", ",
             ex
         }));
     }
     return(result);
 }
Exemplo n.º 3
0
        public override void GenerateCSharpProject(CSharpProject project, string assemblyName, IEnumerable <string> sourceFiles, IEnumerable <string> defines, IEnumerable <CSharpProject> additionalProjectReferences)
        {
            MetroAssemblyCSharpCreator.AssemblyCSharpPlugin plugin;
            string[] strArray2;
            string[] strArray3;
            WSASDK   wsaSDK = EditorUserBuildSettings.wsaSDK;

            if (wsaSDK == WSASDK.UniversalSDK81)
            {
                wsaSDK = WSASDK.SDK81;
            }
            string playbackEngineDirectory = BuildPipeline.GetPlaybackEngineDirectory(BuildTarget.WSAPlayer, BuildOptions.CompressTextures);

            if (additionalProjectReferences != null)
            {
                string directoryName = Path.GetDirectoryName(project.Path);
                foreach (CSharpProject project2 in additionalProjectReferences)
                {
                    string strB = Path.GetDirectoryName(project2.Path);
                    if (string.Compare(directoryName, strB, true) == 0)
                    {
                        throw new Exception($"Projects {directoryName} and {strB} should be in different folders.");
                    }
                }
            }
            List <MetroAssemblyCSharpCreator.AssemblyCSharpPlugin> plugins = new List <MetroAssemblyCSharpCreator.AssemblyCSharpPlugin>();

            string[] strArray = new string[] { ".dll", ".winmd" };
            string   fullPath = Path.GetFullPath(Path.Combine(Application.dataPath, ".."));

            foreach (PluginImporter importer in PluginImporter.GetImporters(BuildTarget.WSAPlayer))
            {
        private string[] GetNETWSAAssemblies(WSASDK wsaSDK)
        {
            if (wsaSDK != WSASDK.UWP || MicrosoftCSharpCompiler.GetCurrentScriptingBackend() == ScriptingImplementation.IL2CPP)
            {
                return(Directory.GetFiles(MicrosoftCSharpCompiler.GetNETCoreFrameworkReferencesDirectory(wsaSDK), "*.dll"));
            }
            NuGetPackageResolver nuGetPackageResolver = new NuGetPackageResolver
            {
                ProjectLockFile = "UWP\\project.lock.json"
            };

            for (int num = (!MicrosoftCSharpCompiler.EnsureProjectLockFile(nuGetPackageResolver)) ? 1 : 2; num != 0; num--)
            {
                try
                {
                    nuGetPackageResolver.Resolve();
                }
                catch (Exception)
                {
                    if (num <= 1)
                    {
                        throw;
                    }
                    Console.WriteLine("Failed to resolve NuGet packages. Deleting \"{0}\" and retrying.", Path.GetFullPath(nuGetPackageResolver.ProjectLockFile));
                    File.Delete(nuGetPackageResolver.ProjectLockFile);
                    MicrosoftCSharpCompiler.EnsureProjectLockFile(nuGetPackageResolver);
                }
            }
            return(nuGetPackageResolver.ResolvedReferences);
        }
Exemplo n.º 5
0
        internal static string GetPlatformAssemblyPath(WSASDK wsaSDK)
        {
            string windowsKitDirectory = MicrosoftCSharpCompiler.GetWindowsKitDirectory(wsaSDK);
            string result;

            if (wsaSDK == WSASDK.UWP)
            {
                string text = Paths.Combine(new string[]
                {
                    windowsKitDirectory,
                    "UnionMetadata",
                    UWPReferences.SdkVersionToString(UWPReferences.GetDesiredSDKVersion()),
                    "Facade",
                    "Windows.winmd"
                });
                if (!File.Exists(text))
                {
                    text = Path.Combine(windowsKitDirectory, "UnionMetadata\\Facade\\Windows.winmd");
                }
                result = text;
            }
            else
            {
                result = Path.Combine(windowsKitDirectory, "References\\CommonConfiguration\\Neutral\\Windows.winmd");
            }
            return(result);
        }
Exemplo n.º 6
0
    public static void BuildAndRun(BuildLaunchPlayerArgs args)
    {
        if (args.target != BuildTarget.WSAPlayer)
        {
            throw new ArgumentException("Invalid build target.", "target");
        }
        if (args.installPath.StartsWith(@"\\") || args.installPath.StartsWith("//"))
        {
            throw new ArgumentException("Can not Build & Run to network share!");
        }
        WSASDK wsaSDK = EditorUserBuildSettings.wsaSDK;

        if (wsaSDK == WSASDK.UniversalSDK81)
        {
            switch (EditorUserBuildSettings.wsaBuildAndRunDeployTarget)
            {
            case WSABuildAndRunDeployTarget.LocalMachine:
                wsaSDK = WSASDK.SDK81;
                break;

            case WSABuildAndRunDeployTarget.WindowsPhone:
                wsaSDK = WSASDK.PhoneSDK81;
                break;
            }
        }
        if (((wsaSDK == WSASDK.UniversalSDK81) || (wsaSDK == WSASDK.UWP)) && (EditorUserBuildSettings.wsaBuildAndRunDeployTarget == WSABuildAndRunDeployTarget.LocalMachineAndWindowsPhone))
        {
            BuildAndRunOnBoth(args, wsaSDK);
        }
        else
        {
            BuildAndRunOnSingle(args, wsaSDK, EditorUserBuildSettings.wsaBuildAndRunDeployTarget);
        }
    }
Exemplo n.º 7
0
    public static string GetMSBuildExePath(WSASDK wsaSDK)
    {
        string str = null;

        switch (wsaSDK)
        {
        case WSASDK.SDK80:
            str = Path.Combine(GetMSBuildPath(wsaSDK), "MSBuild.exe");
            break;

        case WSASDK.SDK81:
        case WSASDK.PhoneSDK81:
        case WSASDK.UniversalSDK81:
        case WSASDK.UWP:
            str = Path.Combine(GetMSBuildPath(wsaSDK), @"Bin\MSBuild.exe");
            break;

        default:
            throw new Exception("Unsupported Windows Store Apps SDK: " + wsaSDK);
        }
        if (string.IsNullOrEmpty(str) || !File.Exists(str))
        {
            throw new Exception($"Failed to locate suitable MSBuild '{str}'");
        }
        return(str);
    }
Exemplo n.º 8
0
        internal static string GetNETCoreFrameworkReferencesDirectory(WSASDK wsaSDK)
        {
            string result;

            if (MicrosoftCSharpCompiler.GetCurrentScriptingBackend() != ScriptingImplementation.IL2CPP)
            {
                switch (wsaSDK)
                {
                case WSASDK.SDK80:
                    result = MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\.NETCore\\v4.5";
                    return(result);

                case WSASDK.SDK81:
                    result = MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\.NETCore\\v4.5.1";
                    return(result);

                case WSASDK.PhoneSDK81:
                    result = MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\WindowsPhoneApp\\v8.1";
                    return(result);

                case WSASDK.UWP:
                    result = null;
                    return(result);
                }
                throw new Exception("Unknown Windows SDK: " + wsaSDK.ToString());
            }
            result = BuildPipeline.GetMonoLibDirectory(BuildTarget.WSAPlayer);
            return(result);
        }
Exemplo n.º 9
0
 internal static void AddAssemblyConverterCommands(string playerPackage, bool sourceBuild, Dictionary <WSASDK, TemplateBuilder> templateBuilders, Dictionary <WSASDK, LibraryCollection> libraryCollections, bool useCSharpProjects = false, Dictionary <WSASDK, string> assemblyCSharpDllPaths = null, Dictionary <WSASDK, string> assemblyCSharpFirstpassDllPaths = null)
 {
     foreach (KeyValuePair <WSASDK, TemplateBuilder> pair in templateBuilders)
     {
         WSASDK key = pair.Key;
         foreach (KeyValuePair <WSASDK, LibraryCollection> pair2 in libraryCollections)
         {
             if (((WSASDK)pair2.Key) == key)
             {
                 string str  = null;
                 string str2 = null;
                 if (assemblyCSharpDllPaths != null)
                 {
                     assemblyCSharpDllPaths.TryGetValue(key, out str);
                 }
                 if (assemblyCSharpFirstpassDllPaths != null)
                 {
                     assemblyCSharpFirstpassDllPaths.TryGetValue(key, out str2);
                 }
                 List <string> assemblies = new List <string>();
                 foreach (Library library in pair2.Value)
                 {
                     if (library.Process && (!useCSharpProjects || (!string.Equals(library.Name, Utility.AssemblyCSharpName, StringComparison.InvariantCultureIgnoreCase) && !string.Equals(library.Name, Utility.AssemblyCSharpFirstPassName, StringComparison.InvariantCultureIgnoreCase))))
                     {
                         assemblies.Add(library.Reference);
                     }
                 }
                 AssemblyConverterCommandAdder.AddCommands(assemblies, key, sourceBuild, pair.Value, useCSharpProjects, str, str2);
             }
         }
     }
 }
        internal static string GetNETCoreFrameworkReferencesDirectory(WSASDK wsaSDK)
        {
            switch (wsaSDK)
            {
            case WSASDK.SDK80:
            {
                string result = MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\.NETCore\\v4.5";
                return(result);
            }

            case WSASDK.SDK81:
            {
                string result = MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\.NETCore\\v4.5.1";
                return(result);
            }

            case WSASDK.PhoneSDK81:
            {
                string result = MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\WindowsPhoneApp\\v8.1";
                return(result);
            }

            case WSASDK.UWP:
            {
                string result = null;
                return(result);
            }
            }
            throw new Exception("Unknown Windows SDK: " + wsaSDK.ToString());
        }
Exemplo n.º 11
0
        public override void PostProcess(BuildPostProcessArgs args)
        {
            PostProcessWSA swsa;
            WSASDK         wsaSDK = EditorUserBuildSettings.wsaSDK;

            switch (wsaSDK)
            {
            case WSASDK.SDK81:
                swsa = new PostProcessStore81(args, null);
                break;

            case WSASDK.PhoneSDK81:
                swsa = new PostProcessPhone81(args, null);
                break;

            case WSASDK.UniversalSDK81:
                swsa = new PostProcessUniversal81(args);
                break;

            case WSASDK.UWP:
                if (PlayerSettings.GetScriptingBackend(BuildTargetGroup.WSA) != ScriptingImplementation.IL2CPP)
                {
                    swsa = new PostProcessUAPDotNet(args, null);
                    break;
                }
                swsa = new PostProcessUAPIl2Cpp(args, null);
                break;

            default:
                throw new NotSupportedException($"{wsaSDK} is not supported.");
            }
            swsa.Process();
        }
Exemplo n.º 12
0
        private string[] GetNETWSAAssemblies(WSASDK wsaSDK)
        {
            if (wsaSDK != WSASDK.UWP)
            {
                return(Directory.GetFiles(GetNETCoreFrameworkReferencesDirectory(wsaSDK), "*.dll"));
            }
            NuGetPackageResolver resolver = new NuGetPackageResolver {
                ProjectLockFile = "project.lock.json"
            };

            for (int i = !EnsureProjectLockFile(resolver) ? 1 : 2; i != 0; i--)
            {
                try
                {
                    resolver.Resolve();
                }
                catch (Exception)
                {
                    if (i <= 1)
                    {
                        throw;
                    }
                    Console.WriteLine("Failed to resolve NuGet packages. Deleting \"{0}\" and retrying.", Path.GetFullPath(resolver.ProjectLockFile));
                    File.Delete(resolver.ProjectLockFile);
                    EnsureProjectLockFile(resolver);
                }
            }
            return(resolver.ResolvedReferences);
        }
 internal static string[] GetAdditionalReferences(WSASDK wsaSDK)
 {
     if (wsaSDK != WSASDK.UWP)
     {
         return(null);
     }
     return(UWPReferences.GetReferences(UWPReferences.GetDesiredSDKVersion()));
 }
Exemplo n.º 14
0
 public PostProcessWSA(BuildPostProcessArgs args, WSASDK sdk, string stagingArea = null) : base(args, sdk, stagingArea)
 {
     this._generateReferenceProjects = EditorUserBuildSettings.wsaGenerateReferenceProjects;
     this._images = new ProjectImages();
     if (this._generateReferenceProjects)
     {
         MetroAssemblyCSharpCreator.ResetAssemblyCSharpProjectGUIDs();
     }
 }
Exemplo n.º 15
0
 public PostProcessWSA(BuildPostProcessArgs args, WSASDK sdk, [Optional, DefaultParameterValue(null)] string stagingArea) : base(args, sdk, stagingArea)
 {
     this._generateReferenceProjects = EditorUserBuildSettings.wsaGenerateReferenceProjects;
     this._images = new ProjectImages();
     if (this._generateReferenceProjects)
     {
         MetroAssemblyCSharpCreator.ResetAssemblyCSharpProjectGUIDs();
     }
 }
        protected static string GetPlatformAssemblyPath(WSASDK wsaSDK)
        {
            string windowsKitDirectory = GetWindowsKitDirectory(wsaSDK);

            if (wsaSDK == WSASDK.UWP)
            {
                return(Path.Combine(windowsKitDirectory, @"UnionMetadata\Facade\Windows.winmd"));
            }
            return(Path.Combine(windowsKitDirectory, @"References\CommonConfiguration\Neutral\Windows.winmd"));
        }
        protected static string GetPlatformAssemblyPath(WSASDK wsaSDK)
        {
            string windowsKitDirectory = MicrosoftCSharpCompiler.GetWindowsKitDirectory(wsaSDK);

            if (wsaSDK == WSASDK.UWP)
            {
                return(Path.Combine(windowsKitDirectory, "UnionMetadata\\Facade\\Windows.winmd"));
            }
            return(Path.Combine(windowsKitDirectory, "References\\CommonConfiguration\\Neutral\\Windows.winmd"));
        }
Exemplo n.º 18
0
 public ApplicationLauncherImpl(string playerPackage, string installPath, string packageName, string configuration, WSASDK wsaSDK, WSASDK globalWSASDK, WSABuildAndRunDeployTarget deployTarget)
 {
     this.playerPackage = playerPackage;
     this.installPath   = installPath;
     this.packageName   = packageName;
     this.configuration = configuration;
     this.wsaSDK        = wsaSDK;
     this.globalWSASDK  = globalWSASDK;
     this.deployTarget  = deployTarget;
     DetermineBuildPlatform(wsaSDK, deployTarget, out this.platform);
     this.scriptingBackend = PlayerSettings.GetScriptingBackend(BuildTargetGroup.WSA);
 }
Exemplo n.º 19
0
 public static void AddCommands(IEnumerable <string> assemblies, WSASDK wsaSDK, bool sourceBuild, TemplateBuilder templateBuilder, bool useAssemblyCSharpProjects, string assemblyCSharpDllPath, string assemblyCSharpFirstpassDllPath)
 {
     new MetroVisualStudioSolutionHelper.AssemblyConverterCommandAdder {
         assemblies                     = assemblies,
         wsaSDK                         = wsaSDK,
         sourceBuild                    = sourceBuild,
         templateBuilder                = templateBuilder,
         useAssemblyCSharpProjects      = useAssemblyCSharpProjects,
         assemblyCSharpDllPath          = assemblyCSharpDllPath,
         assemblyCSharpFirstpassDllPath = assemblyCSharpFirstpassDllPath
     }.Execute();
 }
 internal static string[] GetAdditionalReferences(WSASDK wsaSDK)
 {
     if (wsaSDK != WSASDK.UWP)
     {
         return(null);
     }
     if (_uwpReferences == null)
     {
         _uwpReferences = UWPReferences.GetReferences();
     }
     return(_uwpReferences);
 }
 internal static string[] GetAdditionalReferences(WSASDK wsaSDK)
 {
     if (wsaSDK != WSASDK.UWP)
     {
         return((string[])null);
     }
     if (MicrosoftCSharpCompiler._uwpReferences != null)
     {
         return(MicrosoftCSharpCompiler._uwpReferences);
     }
     MicrosoftCSharpCompiler._uwpReferences = UWPReferences.GetReferences();
     return(MicrosoftCSharpCompiler._uwpReferences);
 }
Exemplo n.º 22
0
 internal static string[] GetAdditionalReferences(WSASDK wsaSDK)
 {
     string[] result;
     if (wsaSDK != WSASDK.UWP)
     {
         result = null;
     }
     else
     {
         result = UWPReferences.GetReferences(UWPReferences.GetDesiredSDKVersion());
     }
     return(result);
 }
		internal static string GetNETCoreFrameworkReferencesDirectory(WSASDK wsaSDK)
		{
			switch (wsaSDK)
			{
			case WSASDK.SDK80:
				return MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\.NETCore\\v4.5";
			case WSASDK.SDK81:
				return MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\.NETCore\\v4.5.1";
			case WSASDK.PhoneSDK81:
				return MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\WindowsPhoneApp\\v8.1";
			default:
				throw new Exception("Unknown Windows SDK: " + wsaSDK.ToString());
			}
		}
Exemplo n.º 24
0
        internal static string GetNETCoreFrameworkReferencesDirectory(WSASDK wsaSDK)
        {
            switch (wsaSDK)
            {
            case WSASDK.SDK80:
                return(ProgramFilesDirectory + @"\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5");

            case WSASDK.SDK81:
                return(ProgramFilesDirectory + @"\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5.1");

            case WSASDK.PhoneSDK81:
                return(ProgramFilesDirectory + @"\Reference Assemblies\Microsoft\Framework\WindowsPhoneApp\v8.1");
            }
            throw new Exception("Unknown Windows SDK: " + wsaSDK.ToString());
        }
Exemplo n.º 25
0
    public static string GetMSBuildPath(WSASDK wsaSDK)
    {
        switch (wsaSDK)
        {
        case WSASDK.SDK80:
            return(GetFrameworkPath());

        case WSASDK.SDK81:
        case WSASDK.PhoneSDK81:
        case WSASDK.UniversalSDK81:
        case WSASDK.UWP:
            return(GetMSBuildPath(GetVSVersion()));
        }
        throw new Exception("Unsupported Windows Store Apps SDK: " + wsaSDK);
    }
Exemplo n.º 26
0
    public static string GetPlayersDirectoryTag(WSASDK sdk)
    {
        switch (sdk)
        {
        case WSASDK.SDK80:
            return("Windows80");

        case WSASDK.SDK81:
            return("Windows81");

        case WSASDK.PhoneSDK81:
            return("WindowsPhone81");

        case WSASDK.UWP:
            return(@"UAP\" + (!Utility.UseIl2CppScriptingBackend() ? "dotnet" : "il2cpp"));
        }
        throw new Exception($"Unknown WSASDK value {sdk}.");
    }
Exemplo n.º 27
0
    internal static string GetSDKPluginTag(WSASDK sdk)
    {
        switch (sdk)
        {
        case WSASDK.SDK80:
            return("SDK");

        case WSASDK.SDK81:
            return("SDK81");

        case WSASDK.PhoneSDK81:
            return("PhoneSDK81");

        case WSASDK.UWP:
            return("UWP");
        }
        throw new Exception("Unknown SDK");
    }
Exemplo n.º 28
0
 internal static string[] GetAdditionalReferences(WSASDK wsaSDK)
 {
     string[] result;
     if (wsaSDK != WSASDK.UWP)
     {
         result = null;
     }
     else if (MicrosoftCSharpCompiler._uwpReferences != null)
     {
         result = MicrosoftCSharpCompiler._uwpReferences;
     }
     else
     {
         MicrosoftCSharpCompiler._uwpReferences = UWPReferences.GetReferences();
         result = MicrosoftCSharpCompiler._uwpReferences;
     }
     return(result);
 }
 internal static string GetNETCoreFrameworkReferencesDirectory(WSASDK wsaSDK)
 {
   if (MicrosoftCSharpCompiler.GetCurrentScriptingBackend() == ScriptingImplementation.IL2CPP)
     return BuildPipeline.GetMonoLibDirectory(BuildTarget.WSAPlayer);
   switch (wsaSDK)
   {
     case WSASDK.SDK80:
       return MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\.NETCore\\v4.5";
     case WSASDK.SDK81:
       return MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\.NETCore\\v4.5.1";
     case WSASDK.PhoneSDK81:
       return MicrosoftCSharpCompiler.ProgramFilesDirectory + "\\Reference Assemblies\\Microsoft\\Framework\\WindowsPhoneApp\\v8.1";
     case WSASDK.UWP:
       return (string) null;
     default:
       throw new Exception("Unknown Windows SDK: " + wsaSDK.ToString());
   }
 }
Exemplo n.º 30
0
        internal static string GetWindowsKitDirectory(WSASDK wsaSDK)
        {
            string text;

            switch (wsaSDK)
            {
            case WSASDK.SDK80:
            {
                text = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0", "InstallationFolder", null);
                string path = "Windows Kits\\8.0";
                goto IL_AD;
            }

            case WSASDK.SDK81:
            {
                text = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1", "InstallationFolder", null);
                string path = "Windows Kits\\8.1";
                goto IL_AD;
            }

            case WSASDK.PhoneSDK81:
            {
                text = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhoneApp\\v8.1", "InstallationFolder", null);
                string path = "Windows Phone Kits\\8.1";
                goto IL_AD;
            }

            case WSASDK.UWP:
            {
                text = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v10.0", "InstallationFolder", null);
                string path = "Windows Kits\\10.0";
                goto IL_AD;
            }
            }
            throw new Exception("Unknown Windows SDK: " + wsaSDK.ToString());
IL_AD:
            if (text == null)
            {
                string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
                string path;
                text = Path.Combine(folderPath, path);
            }
            return(text);
        }
        private string[] GetClassLibraries()
        {
            BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(this.BuildTarget);

            string[] result;
            if (PlayerSettings.GetScriptingBackend(buildTargetGroup) != ScriptingImplementation.WinRTDotNET)
            {
                string        monoAssemblyDirectory = base.GetMonoProfileLibDirectory();
                List <string> list = new List <string>();
                list.AddRange(from dll in MicrosoftCSharpCompiler.GetReferencesFromMonoDistribution()
                              select Path.Combine(monoAssemblyDirectory, dll));
                if (PlayerSettings.GetApiCompatibilityLevel(buildTargetGroup) == ApiCompatibilityLevel.NET_4_6)
                {
                    string path = Path.Combine(monoAssemblyDirectory, "Facades");
                    list.Add(Path.Combine(path, "System.ObjectModel.dll"));
                    list.Add(Path.Combine(path, "System.Runtime.dll"));
                    list.Add(Path.Combine(path, "System.Runtime.InteropServices.WindowsRuntime.dll"));
                    list.Add(Path.Combine(monoAssemblyDirectory, "System.Numerics.dll"));
                    list.Add(Path.Combine(monoAssemblyDirectory, "System.Numerics.Vectors.dll"));
                }
                result = list.ToArray();
            }
            else
            {
                if (this.BuildTarget != BuildTarget.WSAPlayer)
                {
                    throw new InvalidOperationException(string.Format("MicrosoftCSharpCompiler cannot build for .NET Scripting backend for BuildTarget.{0}.", this.BuildTarget));
                }
                WSASDK wSASDK = WSASDK.UWP;
                if (wSASDK != WSASDK.UWP)
                {
                    result = Directory.GetFiles(MicrosoftCSharpCompiler.GetNETCoreFrameworkReferencesDirectory(wSASDK), "*.dll");
                }
                else
                {
                    NuGetPackageResolver nuGetPackageResolver = new NuGetPackageResolver
                    {
                        ProjectLockFile = "UWP\\project.lock.json"
                    };
                    result = nuGetPackageResolver.Resolve();
                }
            }
            return(result);
        }
        private string[] GetNETWSAAssemblies(WSASDK wsaSDK)
        {
            if (MicrosoftCSharpCompiler.GetCurrentScriptingBackend() == ScriptingImplementation.IL2CPP)
            {
                string monoAssemblyDirectory = BuildPipeline.GetMonoLibDirectory(BuildTarget.WSAPlayer);
                return((from dll in MicrosoftCSharpCompiler.GetReferencesFromMonoDistribution()
                        select Path.Combine(monoAssemblyDirectory, dll)).ToArray <string>());
            }
            if (wsaSDK != WSASDK.UWP)
            {
                return(Directory.GetFiles(MicrosoftCSharpCompiler.GetNETCoreFrameworkReferencesDirectory(wsaSDK), "*.dll"));
            }
            NuGetPackageResolver nuGetPackageResolver = new NuGetPackageResolver
            {
                ProjectLockFile = "UWP\\project.lock.json"
            };

            return(nuGetPackageResolver.Resolve());
        }
        private string[] GetNETWSAAssemblies(WSASDK wsaSDK)
        {
            if (MicrosoftCSharpCompiler.GetCurrentScriptingBackend() == ScriptingImplementation.IL2CPP)
            {
                // ISSUE: object of a compiler-generated type is created
                // ISSUE: reference to a compiler-generated method
                return(((IEnumerable <string>)MicrosoftCSharpCompiler.GetReferencesFromMonoDistribution()).Select <string, string>(new Func <string, string>(new MicrosoftCSharpCompiler.\u003CGetNETWSAAssemblies\u003Ec__AnonStoreyB3()
                {
                    monoAssemblyDirectory = BuildPipeline.GetMonoLibDirectory(BuildTarget.WSAPlayer)
                }.\u003C\u003Em__20C)).ToArray <string>());
            }
            if (wsaSDK != WSASDK.UWP)
            {
                return(Directory.GetFiles(MicrosoftCSharpCompiler.GetNETCoreFrameworkReferencesDirectory(wsaSDK), "*.dll"));
            }
            NuGetPackageResolver resolver = new NuGetPackageResolver()
            {
                ProjectLockFile = "UWP\\project.lock.json"
            };

            for (int index = !MicrosoftCSharpCompiler.EnsureProjectLockFile(resolver) ? 1 : 2; index != 0; --index)
            {
                try
                {
                    resolver.Resolve();
                }
                catch (Exception ex)
                {
                    if (index > 1)
                    {
                        Console.WriteLine("Failed to resolve NuGet packages. Deleting \"{0}\" and retrying.", (object)Path.GetFullPath(resolver.ProjectLockFile));
                        File.Delete(resolver.ProjectLockFile);
                        MicrosoftCSharpCompiler.EnsureProjectLockFile(resolver);
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            return(resolver.ResolvedReferences);
        }
 public static void CreateAssemblyCSharp(CSharpProject project, string playerPackage, string assemblyName, LibraryCollection libraryCollection, WSASDK wsaSDK, CSharpProject[] additionalProjectReferences)
 {
     string relativeFinalProjectDirectory = GetRelativeFinalProjectDirectory(wsaSDK);
     List<AssemblyCSharpPlugin> plugins = new List<AssemblyCSharpPlugin>();
     bool includeUnet = false;
     foreach (Library library in libraryCollection)
     {
         if ((!library.Native || library.WinMd) && (!string.Equals(library.Name, Utility.AssemblyCSharpName, StringComparison.InvariantCultureIgnoreCase) && !string.Equals(library.Name, Utility.AssemblyCSharpFirstPassName, StringComparison.InvariantCultureIgnoreCase)))
         {
             if (string.Equals(library.Name, "UnityEngine.Networking", StringComparison.InvariantCultureIgnoreCase))
             {
                 includeUnet = true;
             }
             string reference = library.Reference;
             string str3 = @"Unprocessed\";
             if (library.WinMd && library.Native)
             {
                 str3 = "";
             }
             if (!reference.StartsWith(@"Plugins\", StringComparison.InvariantCultureIgnoreCase))
             {
                 reference = str3 + library.Reference;
             }
             reference = Utility.CombinePath(relativeFinalProjectDirectory, reference);
             AssemblyCSharpPlugin item = new AssemblyCSharpPlugin {
                 Name = library.Name,
                 HintPath = reference
             };
             plugins.Add(item);
         }
     }
     StringBuilder builder = new StringBuilder();
     string str4 = "$(UnityProjectDir)Assets";
     string[] strArray = new string[] { "Plugins", "Standard Assets", "Standard Assets (Mobile)", "Pro Standard Assets" };
     string additionalReferencePath = "";
     if (additionalProjectReferences != null)
     {
         builder.AppendFormat("    <Compile Include=\"{0}\\**\\*.cs\" Exclude=\"{0}\\**\\Editor\\**\\*.cs", str4);
         foreach (string str6 in strArray)
         {
             builder.AppendFormat(@";{0}\{1}\**\*.cs", str4, str6);
         }
         builder.AppendLine("\">");
         if (str4.StartsWith(".."))
         {
             builder.AppendFormat("      <Link>%(RecursiveDir)%(Filename)%(Extension)</Link>", new object[0]);
             builder.AppendLine();
         }
         builder.AppendLine("    </Compile>");
         additionalReferencePath = string.Format("-additionalAssemblyPath=\"{0}\"", MetroVisualStudioSolutionHelper.GetAssemblyCSharpFirstpassDllDir(wsaSDK));
     }
     else
     {
         foreach (string str7 in strArray)
         {
             builder.AppendFormat("    <Compile Include=\"{0}\\{1}\\**\\*.cs\" Exclude=\"{0}\\{1}\\**\\Editor\\**\\*.cs\">", str4, str7);
             builder.AppendLine();
             if (str4.StartsWith(".."))
             {
                 builder.AppendFormat(@"      <Link>{0}\%(RecursiveDir)%(Filename)%(Extension)</Link>", str7);
                 builder.AppendLine();
             }
             builder.AppendLine("    </Compile>");
         }
     }
     if (<>f__am$cache0 == null)
     {
		private string[] GetNETWSAAssemblies(WSASDK wsaSDK)
		{
			return Directory.GetFiles(MicrosoftCSharpCompiler.GetNETCoreFrameworkReferencesDirectory(wsaSDK), "*.dll");
		}
Exemplo n.º 36
0
    public static string GetMSBuildExePath(WSASDK wsaSDK)
    {
        string str = null;
        switch (wsaSDK)
        {
            case WSASDK.SDK80:
                str = Path.Combine(GetMSBuildPath(wsaSDK), "MSBuild.exe");
                break;

            case WSASDK.SDK81:
            case WSASDK.PhoneSDK81:
            case WSASDK.UniversalSDK81:
            case WSASDK.UWP:
                str = Path.Combine(GetMSBuildPath(wsaSDK), @"Bin\MSBuild.exe");
                break;

            default:
                throw new Exception("Unsupported Windows Store Apps SDK: " + wsaSDK);
        }
        if (string.IsNullOrEmpty(str) || !File.Exists(str))
        {
            throw new Exception(string.Format("Failed to locate suitable MSBuild '{0}'", str));
        }
        return str;
    }
 private string[] GetNETWSAAssemblies(WSASDK wsaSDK)
 {
   if (MicrosoftCSharpCompiler.GetCurrentScriptingBackend() == ScriptingImplementation.IL2CPP)
   {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: reference to a compiler-generated method
     return ((IEnumerable<string>) MicrosoftCSharpCompiler.GetReferencesFromMonoDistribution()).Select<string, string>(new Func<string, string>(new MicrosoftCSharpCompiler.\u003CGetNETWSAAssemblies\u003Ec__AnonStoreyB3() { monoAssemblyDirectory = BuildPipeline.GetMonoLibDirectory(BuildTarget.WSAPlayer) }.\u003C\u003Em__20C)).ToArray<string>();
   }
   if (wsaSDK != WSASDK.UWP)
     return Directory.GetFiles(MicrosoftCSharpCompiler.GetNETCoreFrameworkReferencesDirectory(wsaSDK), "*.dll");
   NuGetPackageResolver resolver = new NuGetPackageResolver() { ProjectLockFile = "UWP\\project.lock.json" };
   for (int index = !MicrosoftCSharpCompiler.EnsureProjectLockFile(resolver) ? 1 : 2; index != 0; --index)
   {
     try
     {
       resolver.Resolve();
     }
     catch (Exception ex)
     {
       if (index > 1)
       {
         Console.WriteLine("Failed to resolve NuGet packages. Deleting \"{0}\" and retrying.", (object) Path.GetFullPath(resolver.ProjectLockFile));
         File.Delete(resolver.ProjectLockFile);
         MicrosoftCSharpCompiler.EnsureProjectLockFile(resolver);
       }
       else
         throw;
     }
   }
   return resolver.ResolvedReferences;
 }
Exemplo n.º 38
0
    public static string GetMSBuildPath(WSASDK wsaSDK)
    {
        switch (wsaSDK)
        {
            case WSASDK.SDK80:
                return GetFrameworkPath();

            case WSASDK.SDK81:
            case WSASDK.PhoneSDK81:
            case WSASDK.UniversalSDK81:
            case WSASDK.UWP:
                return GetMSBuildPath(GetVSVersion());
        }
        throw new Exception("Unsupported Windows Store Apps SDK: " + wsaSDK);
    }
 protected static string GetPlatformAssemblyPath(WSASDK wsaSDK)
 {
   string windowsKitDirectory = MicrosoftCSharpCompiler.GetWindowsKitDirectory(wsaSDK);
   if (wsaSDK == WSASDK.UWP)
     return Path.Combine(windowsKitDirectory, "UnionMetadata\\Facade\\Windows.winmd");
   return Path.Combine(windowsKitDirectory, "References\\CommonConfiguration\\Neutral\\Windows.winmd");
 }
 internal static string[] GetAdditionalReferences(WSASDK wsaSDK)
 {
   if (wsaSDK != WSASDK.UWP)
     return (string[]) null;
   if (MicrosoftCSharpCompiler._uwpReferences != null)
     return MicrosoftCSharpCompiler._uwpReferences;
   MicrosoftCSharpCompiler._uwpReferences = UWPReferences.GetReferences();
   return MicrosoftCSharpCompiler._uwpReferences;
 }
 internal static string GetWindowsKitDirectory(WSASDK wsaSDK)
 {
   string str;
   string path2;
   switch (wsaSDK)
   {
     case WSASDK.SDK80:
       str = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0", "InstallationFolder", (string) null);
       path2 = "Windows Kits\\8.0";
       break;
     case WSASDK.SDK81:
       str = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1", "InstallationFolder", (string) null);
       path2 = "Windows Kits\\8.1";
       break;
     case WSASDK.PhoneSDK81:
       str = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhoneApp\\v8.1", "InstallationFolder", (string) null);
       path2 = "Windows Phone Kits\\8.1";
       break;
     case WSASDK.UWP:
       str = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v10.0", "InstallationFolder", (string) null);
       path2 = "Windows Kits\\10.0";
       break;
     default:
       throw new Exception("Unknown Windows SDK: " + wsaSDK.ToString());
   }
   if (str == null)
     str = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), path2);
   return str;
 }
 private void FillNETCoreCompilerOptions(WSASDK wsaSDK, List<string> arguments, ref string argsPrefix)
 {
   argsPrefix = "/noconfig ";
   arguments.Add("/nostdlib+");
   if (MicrosoftCSharpCompiler.GetCurrentScriptingBackend() != ScriptingImplementation.IL2CPP)
     arguments.Add("/define:NETFX_CORE");
   arguments.Add("/preferreduilang:en-US");
   string platformAssemblyPath = MicrosoftCSharpCompiler.GetPlatformAssemblyPath(wsaSDK);
   string str1;
   switch (wsaSDK)
   {
     case WSASDK.SDK80:
       str1 = "8.0";
       break;
     case WSASDK.SDK81:
       str1 = "8.1";
       break;
     case WSASDK.PhoneSDK81:
       str1 = "Phone 8.1";
       break;
     case WSASDK.UWP:
       str1 = "UAP";
       if (MicrosoftCSharpCompiler.GetCurrentScriptingBackend() != ScriptingImplementation.IL2CPP)
       {
         arguments.Add("/define:WINDOWS_UWP");
         break;
       }
       break;
     default:
       throw new Exception("Unknown Windows SDK: " + EditorUserBuildSettings.wsaSDK.ToString());
   }
   if (!File.Exists(platformAssemblyPath))
     throw new Exception(string.Format("'{0}' not found, do you have Windows {1} SDK installed?", (object) platformAssemblyPath, (object) str1));
   arguments.Add("/reference:\"" + platformAssemblyPath + "\"");
   string[] additionalReferences = MicrosoftCSharpCompiler.GetAdditionalReferences(wsaSDK);
   if (additionalReferences != null)
   {
     foreach (string str2 in additionalReferences)
       arguments.Add("/reference:\"" + str2 + "\"");
   }
   foreach (string netwsaAssembly in this.GetNETWSAAssemblies(wsaSDK))
     arguments.Add("/reference:\"" + netwsaAssembly + "\"");
   if (MicrosoftCSharpCompiler.GetCurrentScriptingBackend() == ScriptingImplementation.IL2CPP)
     return;
   string path;
   string contents;
   string path2;
   switch (wsaSDK)
   {
     case WSASDK.SDK80:
       path = Path.Combine(Path.GetTempPath(), ".NETCore,Version=v4.5.AssemblyAttributes.cs");
       contents = this.GetNetWSAAssemblyInfoWindows80();
       path2 = "Managed\\WinRTLegacy.dll";
       break;
     case WSASDK.SDK81:
       path = Path.Combine(Path.GetTempPath(), ".NETCore,Version=v4.5.1.AssemblyAttributes.cs");
       contents = this.GetNetWSAAssemblyInfoWindows81();
       path2 = "Managed\\WinRTLegacy.dll";
       break;
     case WSASDK.PhoneSDK81:
       path = Path.Combine(Path.GetTempPath(), "WindowsPhoneApp,Version=v8.1.AssemblyAttributes.cs");
       contents = this.GetNetWSAAssemblyInfoWindowsPhone81();
       path2 = "Managed\\Phone\\WinRTLegacy.dll";
       break;
     case WSASDK.UWP:
       path = Path.Combine(Path.GetTempPath(), ".NETCore,Version=v5.0.AssemblyAttributes.cs");
       contents = this.GetNetWSAAssemblyInfoUWP();
       path2 = "Managed\\UAP\\WinRTLegacy.dll";
       break;
     default:
       throw new Exception("Unknown Windows SDK: " + EditorUserBuildSettings.wsaSDK.ToString());
   }
   string str3 = Path.Combine(BuildPipeline.GetPlaybackEngineDirectory(this._island._target, BuildOptions.None), path2);
   arguments.Add("/reference:\"" + str3.Replace('/', '\\') + "\"");
   if (File.Exists(path))
     File.Delete(path);
   File.WriteAllText(path, contents);
   arguments.Add(path);
 }
		protected static string GetPlatformAssemblyPath(WSASDK wsaSDK)
		{
			string text;
			string path;
			switch (wsaSDK)
			{
			case WSASDK.SDK80:
				text = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0", "InstallationFolder");
				path = "Windows Kits\\8.0";
				break;
			case WSASDK.SDK81:
				text = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.1", "InstallationFolder");
				path = "Windows Kits\\8.1";
				break;
			case WSASDK.PhoneSDK81:
				text = RegistryUtil.GetRegistryStringValue32("SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhoneApp\\v8.1", "InstallationFolder");
				path = "Windows Phone Kits\\8.1";
				break;
			default:
				throw new Exception("Unknown Windows SDK: " + wsaSDK.ToString());
			}
			if (text == null)
			{
				string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
				text = Path.Combine(folderPath, path);
			}
			return Path.Combine(text, "References\\CommonConfiguration\\Neutral\\Windows.winmd");
		}
		private void FillNETCoreCompilerOptions(WSASDK wsaSDK, List<string> arguments, ref string argsPrefix)
		{
			argsPrefix = "/noconfig ";
			arguments.Add("/nostdlib+");
			arguments.Add("/define:NETFX_CORE");
			string platformAssemblyPath = MicrosoftCSharpCompiler.GetPlatformAssemblyPath(wsaSDK);
			string arg;
			switch (wsaSDK)
			{
			case WSASDK.SDK80:
				arg = "8.0";
				break;
			case WSASDK.SDK81:
				arg = "8.1";
				break;
			case WSASDK.PhoneSDK81:
				arg = "Phone 8.1";
				break;
			default:
				throw new Exception("Unknown Windows SDK: " + EditorUserBuildSettings.wsaSDK.ToString());
			}
			if (!File.Exists(platformAssemblyPath))
			{
				throw new Exception(string.Format("'{0}' not found, do you have Windows {1} SDK installed?", platformAssemblyPath, arg));
			}
			arguments.Add("/reference:\"" + platformAssemblyPath + "\"");
			string[] nETWSAAssemblies = this.GetNETWSAAssemblies(wsaSDK);
			for (int i = 0; i < nETWSAAssemblies.Length; i++)
			{
				string str = nETWSAAssemblies[i];
				arguments.Add("/reference:\"" + str + "\"");
			}
			string text;
			string contents;
			switch (wsaSDK)
			{
			case WSASDK.SDK80:
				text = Path.Combine(Path.GetTempPath(), ".NETCore,Version=v4.5.AssemblyAttributes.cs");
				contents = this.GetNetWSAAssemblyInfoWindows80();
				break;
			case WSASDK.SDK81:
				text = Path.Combine(Path.GetTempPath(), ".NETCore,Version=v4.5.1.AssemblyAttributes.cs");
				contents = this.GetNetWSAAssemblyInfoWindows81();
				break;
			case WSASDK.PhoneSDK81:
				text = Path.Combine(Path.GetTempPath(), "WindowsPhoneApp,Version=v8.1.AssemblyAttributes.cs");
				contents = this.GetNetWSAAssemblyInfoWindowsPhone81();
				break;
			default:
				throw new Exception("Unknown Windows SDK: " + EditorUserBuildSettings.wsaSDK.ToString());
			}
			if (File.Exists(text))
			{
				File.Delete(text);
			}
			File.WriteAllText(text, contents);
			arguments.Add(text);
			string text2 = Path.Combine(BuildPipeline.GetPlaybackEngineDirectory(this._island._target, BuildOptions.None), "Managed\\WinRTLegacy.dll");
			arguments.Add("/reference:\"" + text2.Replace('/', '\\') + "\"");
		}
Exemplo n.º 45
0
 protected static string GetReferenceAssembliesDirectory(WSASDK sdk)
 {
     return PostProcessWinRT.GetReferenceAssembliesDirectory(MicrosoftCSharpCompiler.GetNETCoreFrameworkReferencesDirectory(sdk));
 }