public static void OpenWindow() { BuildDeployWindow window = GetWindow <BuildDeployWindow>("Build Window") as BuildDeployWindow; if (window != null) { window.Show(); } }
public static bool BuildAppxFromSolution(string productName, string msBuildVersion, bool forceRebuildAppx, string buildConfig, string buildDirectory, bool incrementVersion) { // Get and validate the msBuild path... string vs = CalcMSBuildPath(msBuildVersion); if (!File.Exists(vs)) { Debug.LogError("MSBuild.exe is missing or invalid (path=" + vs + "). Note that the default version is " + DefaultMSBuildVersion); return(false); } // Get the path to the NuGet tool string unity = Path.GetDirectoryName(EditorApplication.applicationPath); string nugetPath = Path.Combine(unity, @"Data\PlaybackEngines\MetroSupport\Tools\NuGet.exe"); string storePath = Path.GetFullPath(Path.Combine(Path.Combine(Application.dataPath, ".."), buildDirectory)); string solutionProjectPath = Path.GetFullPath(Path.Combine(storePath, productName + @".sln")); // Before building, need to run a nuget restore to generate a json.lock file. Failing to do // this breaks the build in VS RTM var nugetPInfo = new System.Diagnostics.ProcessStartInfo(); nugetPInfo.FileName = nugetPath; nugetPInfo.WorkingDirectory = buildDirectory; nugetPInfo.UseShellExecute = false; nugetPInfo.Arguments = @"restore " + PlayerSettings.productName + "/project.json"; using (var nugetP = new System.Diagnostics.Process()) { Debug.Log(nugetPath + " " + nugetPInfo.Arguments); nugetP.StartInfo = nugetPInfo; nugetP.Start(); nugetP.WaitForExit(); } // Ensure that the generated .appx version increments by modifying // Package.appxmanifest if (incrementVersion) { IncrementPackageVersion(); } // Now do the actual build var pinfo = new System.Diagnostics.ProcessStartInfo(); pinfo.FileName = vs; pinfo.UseShellExecute = false; string buildType = forceRebuildAppx ? "Rebuild" : "Build"; pinfo.Arguments = string.Format("\"{0}\" /t:{2} /p:Configuration={1} /p:Platform=x86", solutionProjectPath, buildConfig, buildType); var p = new System.Diagnostics.Process(); Debug.Log(vs + " " + pinfo.Arguments); p.StartInfo = pinfo; p.Start(); p.WaitForExit(); if (p.ExitCode == 0) { Debug.Log("APPX build succeeded!"); } else { Debug.LogError("MSBuild error (code = " + p.ExitCode + ")"); } if (p.ExitCode != 0) { EditorUtility.DisplayDialog(PlayerSettings.productName + " build Failed!", "Failed to build appx from solution. Error code: " + p.ExitCode, "OK"); return(false); } else { // Build succeeded. Allow user to install build on remote PC BuildDeployWindow.OpenWindow(); return(true); } }