diff --git a/package/CHANGELOG.md b/package/CHANGELOG.md index 05ac6cce0..1b8aead61 100755 --- a/package/CHANGELOG.md +++ b/package/CHANGELOG.md @@ -1,6 +1,6 @@ # Code Editor Package for Visual Studio -## [1.0.1] - 2019-01-01 +## [1.0.2] - 2019-01-01 ### This is the first release of *Unity Package visualstudio_editor*. diff --git a/package/Editor/COMIntegration/Debug/COMIntegration.exe b/package/Editor/COMIntegration/Debug/COMIntegration.exe index cc67cbeff..a77822e76 100755 Binary files a/package/Editor/COMIntegration/Debug/COMIntegration.exe and b/package/Editor/COMIntegration/Debug/COMIntegration.exe differ diff --git a/package/Editor/ProjectGeneration.cs b/package/Editor/ProjectGeneration.cs index 231d6dcf3..09414a626 100755 --- a/package/Editor/ProjectGeneration.cs +++ b/package/Editor/ProjectGeneration.cs @@ -559,22 +559,12 @@ public string SolutionFile() IEnumerable responseFilesData ) { - string targetFrameworkVersion; - string targetLanguageVersion; var toolsVersion = "4.0"; var productVersion = "10.0.20506"; const string baseDirectory = "."; - if (island.compilerOptions.ApiCompatibilityLevel == ApiCompatibilityLevel.NET_4_6) - { - targetFrameworkVersion = "v4.7.1"; - targetLanguageVersion = "latest"; - } - else - { - targetFrameworkVersion = "v3.5"; - targetLanguageVersion = "4"; - } + var targetFrameworkVersion = "v4.7.1"; + var targetLanguageVersion = "latest"; var arguments = new object[] { diff --git a/package/Editor/VSEditor.cs b/package/Editor/VSEditor.cs index b8922c857..7dfca372e 100755 --- a/package/Editor/VSEditor.cs +++ b/package/Editor/VSEditor.cs @@ -34,7 +34,11 @@ public class VSEditor : IExternalCodeEditor static IEnumerable FindVisualStudioDevEnvPaths() { - var asset = AssetDatabase.FindAssets("VSWhere a:packages").Select(AssetDatabase.GUIDToAssetPath).First(assetPath => assetPath.Contains("vswhere.exe")); + string asset = AssetDatabase.FindAssets("VSWhere a:packages").Select(AssetDatabase.GUIDToAssetPath).FirstOrDefault(assetPath => assetPath.Contains("vswhere.exe")); + if (string.IsNullOrWhiteSpace(asset)) // This may be called too early where the asset database has not replicated this information yet. + { + yield break; + } UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath(asset); var progpath = packageInfo.resolvedPath + asset.Substring("Packages/com.unity.ide.visualstudio".Length); var process = new Process @@ -73,13 +77,10 @@ static VSEditor() var editor = new VSEditor(new Discovery(), new ProjectGeneration()); CodeEditor.Register(editor); var current = CodeEditor.CurrentEditorInstallation; - foreach (string[] paths in InstalledVisualStudios.Values) + if (editor.TryGetInstallationForPath(current, out var installation)) { - if (paths.Contains(current)) - { - editor.CreateIfDoesntExist(); - return; - } + editor.Initialize(current); + return; } } @@ -357,22 +358,34 @@ public void SyncAll() public void Initialize(string editorInstallationPath) { + CreateIfDoesntExist(); m_Initiliazer.Initialize(editorInstallationPath, InstalledVisualStudios); } public bool OpenProject(string path, int line, int column) { var comAssetPath = AssetDatabase.FindAssets("COMIntegration a:packages").Select(AssetDatabase.GUIDToAssetPath).First(assetPath => assetPath.Contains("COMIntegration.exe")); + if (string.IsNullOrWhiteSpace(comAssetPath)) // This may be called too early where the asset database has not replicated this information yet. + { + return false; + } UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath(comAssetPath); var progpath = packageInfo.resolvedPath + comAssetPath.Substring("Packages/com.unity.ide.visualstudio".Length); - var solution = GetSolutionFile(path); // TODO: If solution file doesn't exist resync. + var fileInfo = new FileInfo(path).FullName; + + var solution = GetSolutionFile(path); + if (solution == "") + { + m_Generation.Sync(); + solution = GetSolutionFile(path); + } solution = solution == "" ? "" : $"\"{solution}\""; var process = new Process { StartInfo = new ProcessStartInfo { FileName = progpath, - Arguments = $"\"{CodeEditor.CurrentEditorInstallation}\" \"{path}\" {solution} {line}", + Arguments = $"\"{CodeEditor.CurrentEditorInstallation}\" \"{fileInfo}\" {solution} {line}", CreateNoWindow = true, UseShellExecute = false, RedirectStandardOutput = true, @@ -383,12 +396,13 @@ public bool OpenProject(string path, int line, int column) while (!process.StandardOutput.EndOfStream) { - if (process.StandardOutput.ReadLine() == "displayProgressBar") + var outputLine = process.StandardOutput.ReadLine(); + if (outputLine == "displayProgressBar") { EditorUtility.DisplayProgressBar("Opening Visual Studio", "Starting up Visual Studio, this might take some time.", .5f); } - if (process.StandardOutput.ReadLine() == "clearprogressbar") + if (outputLine == "clearprogressbar") { EditorUtility.ClearProgressBar(); } diff --git a/package/package.json b/package/package.json index 3a6496c39..893ed2768 100755 --- a/package/package.json +++ b/package/package.json @@ -2,16 +2,16 @@ "name": "com.unity.ide.visualstudio", "displayName": "Visual Studio Editor", "description": "Code editor integration for supporting Visual Studio as code editor for unity. Adds support for generating csproj files for intellisense purposes, auto discovery of installations, etc.", - "version": "1.0.1", + "version": "1.0.2", "unity": "2019.2", "unityRelease": "0a7", "dependencies": {}, "relatedPackages": { - "com.unity.ide.visualstudio.tests": "1.0.1" + "com.unity.ide.visualstudio.tests": "1.0.2" }, "repository": { "type": "git", "url": "git@github.cds.internal.unity3d.com:unity/com.unity.ide.visualstudio.git", - "revision": "01f8b1736d13644871b17ddd5f18a3ef99d98e9a" + "revision": "34da9a734db5b16dfe722ac5371dac8c09099597" } } diff --git a/versions.txt b/versions.txt index 2373e57b4..4fd1a8568 100755 --- a/versions.txt +++ b/versions.txt @@ -6,3 +6,4 @@ 0.1.0-preview.11 1.0.0 1.0.1 +1.0.2