com.unity.ide.visualstudio@2.0.22

## [2.0.22] - 2023-10-03

Integration:

- Add support for `XDG_DATA_DIRS` and `.desktop` files on Linux for `VS Code` discovery.
- Use compile-time platform-specifics instead of using runtime conditions.

Project generation:

- Suppress `USG0001` warnings.
- Mark referenced assemblies as private (to not copy extra files to output directory when building).
- Add Unity capability to SDK-Style projects.
- Prevent circular dependency errors with SDK-Style projects.
This commit is contained in:
Unity Technologies
2023-10-03 00:00:00 +00:00
parent 9fed958a9e
commit b28f5a3cbf
15 changed files with 203 additions and 80 deletions

View File

@@ -13,11 +13,13 @@ namespace Microsoft.Unity.VisualStudio.Editor
{
public static IEnumerable<IVisualStudioInstallation> GetVisualStudioInstallations()
{
#if UNITY_EDITOR_WIN
foreach (var installation in VisualStudioForWindowsInstallation.GetVisualStudioInstallations())
yield return installation;
#elif UNITY_EDITOR_OSX
foreach (var installation in VisualStudioForMacInstallation.GetVisualStudioInstallations())
yield return installation;
#endif
foreach (var installation in VisualStudioCodeInstallation.GetVisualStudioInstallations())
yield return installation;
@@ -27,12 +29,13 @@ namespace Microsoft.Unity.VisualStudio.Editor
{
try
{
#if UNITY_EDITOR_WIN
if (VisualStudioForWindowsInstallation.TryDiscoverInstallation(editorPath, out installation))
return true;
#elif UNITY_EDITOR_OSX
if (VisualStudioForMacInstallation.TryDiscoverInstallation(editorPath, out installation))
return true;
#endif
if (VisualStudioCodeInstallation.TryDiscoverInstallation(editorPath, out installation))
return true;
}
@@ -46,8 +49,11 @@ namespace Microsoft.Unity.VisualStudio.Editor
public static void Initialize()
{
#if UNITY_EDITOR_WIN
VisualStudioForWindowsInstallation.Initialize();
#elif UNITY_EDITOR_OSX
VisualStudioForMacInstallation.Initialize();
#endif
VisualStudioCodeInstallation.Initialize();
}
}

View File

@@ -27,9 +27,7 @@ namespace Microsoft.Unity.VisualStudio.Editor.Messaging
private void SetIOControl()
{
if (!VisualStudioEditor.IsWindows)
return;
#if UNITY_EDITOR_WIN
try
{
const int SIO_UDP_CONNRESET = -1744830452;
@@ -40,6 +38,7 @@ namespace Microsoft.Unity.VisualStudio.Editor.Messaging
{
// fallback
}
#endif
}
public static byte[] BufferFor(IAsyncResult result)

View File

@@ -61,15 +61,18 @@ namespace Microsoft.Unity.VisualStudio.Editor
return CompilationPipeline.GetAssemblyNameFromScriptPath(path);
}
internal static readonly string AssemblyOutput = @"Temp\bin\Debug\".NormalizePathSeparators();
internal static readonly string PlayerAssemblyOutput = @"Temp\bin\Debug\Player\".NormalizePathSeparators();
public IEnumerable<Assembly> GetAssemblies(Func<string, bool> shouldFileBePartOfSolution)
{
IEnumerable<Assembly> assemblies = GetAssembliesByType(AssembliesType.Editor, shouldFileBePartOfSolution, @"Temp\Bin\Debug\");
IEnumerable<Assembly> assemblies = GetAssembliesByType(AssembliesType.Editor, shouldFileBePartOfSolution, AssemblyOutput);
if (!ProjectGenerationFlag.HasFlag(ProjectGenerationFlag.PlayerAssemblies))
{
return assemblies;
}
var playerAssemblies = GetAssembliesByType(AssembliesType.Player, shouldFileBePartOfSolution, @"Temp\Bin\Debug\Player\");
var playerAssemblies = GetAssembliesByType(AssembliesType.Player, shouldFileBePartOfSolution, PlayerAssemblyOutput);
return assemblies.Concat(playerAssemblies);
}
@@ -98,7 +101,8 @@ namespace Microsoft.Unity.VisualStudio.Editor
public string GetCompileOutputPath(string assemblyName)
{
return assemblyName.EndsWith(".Player", StringComparison.Ordinal) ? @"Temp\Bin\Debug\Player\" : @"Temp\Bin\Debug\";
// We need to keep this one for API surface check (AssemblyNameProvider is public), but not used anymore
throw new NotImplementedException();
}
public IEnumerable<string> GetAllAssetPaths()
@@ -207,7 +211,10 @@ namespace Microsoft.Unity.VisualStudio.Editor
public string GetAssemblyName(string assemblyOutputPath, string assemblyName)
{
return assemblyOutputPath.EndsWith(@"\Player\", StringComparison.Ordinal) ? assemblyName + ".Player" : assemblyName;
if (assemblyOutputPath == PlayerAssemblyOutput)
return assemblyName + ".Player";
return assemblyName;
}
}
}

View File

@@ -12,6 +12,8 @@ namespace Microsoft.Unity.VisualStudio.Editor
internal class LegacyStyleProjectGeneration : ProjectGeneration
{
internal override string StyleName => "Legacy";
public LegacyStyleProjectGeneration(string tempDirectory, IAssemblyNameProvider assemblyNameProvider, IFileIO fileIoProvider, IGUIDGenerator guidGenerator) : base(tempDirectory, assemblyNameProvider, fileIoProvider, guidGenerator)
{
}
@@ -82,7 +84,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
internal override void GetProjectFooter(StringBuilder footerBuilder)
{
footerBuilder.Append(string.Join(k_WindowsNewline,
@" <Import Project=""$(MSBuildToolsPath)\Microsoft.CSharp.targets"" />",
$" <Import Project=\"{@"$(MSBuildToolsPath)\Microsoft.CSharp.targets".NormalizePathSeparators()}\" />",
@" <Target Name=""GenerateTargetFrameworkMonikerAttribute"" />",
@" <!-- To modify your build process, add your task inside one of the targets below and uncomment it.",
@" Other similar extension points exist, see Microsoft.Common.targets.",

View File

@@ -87,6 +87,8 @@ namespace Microsoft.Unity.VisualStudio.Editor
SetupProjectSupportedExtensions();
}
internal virtual string StyleName => "";
/// <summary>
/// Syncs the scripting solution if any affected files are relevant.
/// </summary>
@@ -586,6 +588,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
var escapedFullPath = EscapedRelativePathFor(fullReference, out _);
projectBuilder.Append(@" <Reference Include=""").Append(Path.GetFileNameWithoutExtension(escapedFullPath)).Append(@""">").Append(k_WindowsNewline);
projectBuilder.Append(" <HintPath>").Append(escapedFullPath).Append("</HintPath>").Append(k_WindowsNewline);
projectBuilder.Append(" <Private>False</Private>").Append(k_WindowsNewline);
projectBuilder.Append(" </Reference>").Append(k_WindowsNewline);
}
@@ -594,7 +597,11 @@ namespace Microsoft.Unity.VisualStudio.Editor
return Path.Combine(ProjectDirectory, $"{m_AssemblyNameProvider.GetAssemblyName(assembly.outputPath, assembly.name)}.csproj");
}
private static readonly Regex InvalidCharactersRegexPattern = new Regex(@"\?|&|\*|""|<|>|\||#|%|\^|;" + (VisualStudioEditor.IsWindows ? "" : "|:"));
#if UNITY_EDITOR_WIN
private static readonly Regex InvalidCharactersRegexPattern = new Regex(@"\?|&|\*|""|<|>|\||#|%|\^|;", RegexOptions.Compiled);
#else
private static readonly Regex InvalidCharactersRegexPattern = new Regex(@"\?|&|\*|""|<|>|\||#|%|\^|;|:", RegexOptions.Compiled);
#endif
public string SolutionFile()
{
@@ -763,6 +770,8 @@ namespace Microsoft.Unity.VisualStudio.Editor
internal static void GetProjectHeaderConfigurations(ProjectProperties properties, StringBuilder headerBuilder)
{
const string NoWarn = "0169;USG0001";
headerBuilder.Append(@" <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "">").Append(k_WindowsNewline);
headerBuilder.Append(@" <DebugSymbols>true</DebugSymbols>").Append(k_WindowsNewline);
headerBuilder.Append(@" <DebugType>full</DebugType>").Append(k_WindowsNewline);
@@ -771,16 +780,16 @@ namespace Microsoft.Unity.VisualStudio.Editor
headerBuilder.Append(@" <DefineConstants>").Append(string.Join(";", properties.Defines)).Append(@"</DefineConstants>").Append(k_WindowsNewline);
headerBuilder.Append(@" <ErrorReport>prompt</ErrorReport>").Append(k_WindowsNewline);
headerBuilder.Append(@" <WarningLevel>4</WarningLevel>").Append(k_WindowsNewline);
headerBuilder.Append(@" <NoWarn>0169</NoWarn>").Append(k_WindowsNewline);
headerBuilder.Append(@" <NoWarn>").Append(NoWarn).Append("</NoWarn>").Append(k_WindowsNewline);
headerBuilder.Append(@" <AllowUnsafeBlocks>").Append(properties.Unsafe).Append(@"</AllowUnsafeBlocks>").Append(k_WindowsNewline);
headerBuilder.Append(@" </PropertyGroup>").Append(k_WindowsNewline);
headerBuilder.Append(@" <PropertyGroup Condition="" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "">").Append(k_WindowsNewline);
headerBuilder.Append(@" <DebugType>pdbonly</DebugType>").Append(k_WindowsNewline);
headerBuilder.Append(@" <Optimize>true</Optimize>").Append(k_WindowsNewline);
headerBuilder.Append(@" <OutputPath>Temp\bin\Release\</OutputPath>").Append(k_WindowsNewline);
headerBuilder.Append($" <OutputPath>{@"Temp\bin\Release\".NormalizePathSeparators()}</OutputPath>").Append(k_WindowsNewline);
headerBuilder.Append(@" <ErrorReport>prompt</ErrorReport>").Append(k_WindowsNewline);
headerBuilder.Append(@" <WarningLevel>4</WarningLevel>").Append(k_WindowsNewline);
headerBuilder.Append(@" <NoWarn>0169</NoWarn>").Append(k_WindowsNewline);
headerBuilder.Append(@" <NoWarn>").Append(NoWarn).Append("</NoWarn>").Append(k_WindowsNewline);
headerBuilder.Append(@" <AllowUnsafeBlocks>").Append(properties.Unsafe).Append(@"</AllowUnsafeBlocks>").Append(k_WindowsNewline);
headerBuilder.Append(@" </PropertyGroup>").Append(k_WindowsNewline);
}
@@ -822,7 +831,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
}
}
internal static void GetProjectHeaderVstuFlavoring(ProjectProperties properties, StringBuilder headerBuilder, bool includeProjectTypeGuids = true)
internal void GetProjectHeaderVstuFlavoring(ProjectProperties properties, StringBuilder headerBuilder, bool includeProjectTypeGuids = true)
{
// Flavoring
headerBuilder.Append(@" <PropertyGroup>").Append(k_WindowsNewline);
@@ -834,6 +843,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
headerBuilder.Append(@" <UnityProjectGenerator>Package</UnityProjectGenerator>").Append(k_WindowsNewline);
headerBuilder.Append(@" <UnityProjectGeneratorVersion>").Append(properties.FlavoringPackageVersion).Append(@"</UnityProjectGeneratorVersion>").Append(k_WindowsNewline);
headerBuilder.Append(@" <UnityProjectGeneratorStyle>").Append(StyleName).Append("</UnityProjectGeneratorStyle>").Append(k_WindowsNewline);
headerBuilder.Append(@" <UnityProjectType>").Append(properties.FlavoringProjectType).Append(@"</UnityProjectType>").Append(k_WindowsNewline);
headerBuilder.Append(@" <UnityBuildTarget>").Append(properties.FlavoringBuildTarget).Append(@"</UnityBuildTarget>").Append(k_WindowsNewline);
headerBuilder.Append(@" <UnityVersion>").Append(properties.FlavoringUnityVersion).Append(@"</UnityVersion>").Append(k_WindowsNewline);

View File

@@ -4,6 +4,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
using System;
using System.IO;
using System.Text;
using UnityEditor.Compilation;
@@ -13,6 +14,8 @@ namespace Microsoft.Unity.VisualStudio.Editor
{
internal class SdkStyleProjectGeneration : ProjectGeneration
{
internal override string StyleName => "SDK";
internal class SdkStyleAssemblyNameProvider : AssemblyNameProvider
{
// disable PlayerGeneration with SdkStyle projects
@@ -27,12 +30,42 @@ namespace Microsoft.Unity.VisualStudio.Editor
{
}
internal static readonly string[] SupportedCapabilities = new string[]
{
"Unity",
};
internal static readonly string[] UnsupportedCapabilities = new string[]
{
"LaunchProfiles",
"SharedProjectReferences",
"ReferenceManagerSharedProjects",
"ProjectReferences",
"ReferenceManagerProjects",
"COMReferences",
"ReferenceManagerCOM",
"AssemblyReferences",
"ReferenceManagerAssemblies",
};
internal override void GetProjectHeader(ProjectProperties properties, out StringBuilder headerBuilder)
{
headerBuilder = new StringBuilder();
headerBuilder.Append(@"<Project ToolsVersion=""Current"" Sdk=""Microsoft.NET.Sdk"">").Append(k_WindowsNewline);
headerBuilder.Append(@"<Project ToolsVersion=""Current"">").Append(k_WindowsNewline);
headerBuilder.Append(@" <!-- Generated file, do not modify, your changes will be overwritten (use AssetPostprocessor.OnGeneratedCSProject) -->").Append(k_WindowsNewline);
// Prevent circular dependency issues see https://github.com/microsoft/vscode-dotnettools/issues/401
// We need a dedicated subfolder for each project in obj, else depending on the build order, nuget cache files could be overwritten
// We need to do this before common.props, else we'll have a MSB3539 The value of the property "BaseIntermediateOutputPath" was modified after it was used by MSBuild
headerBuilder.Append(@" <PropertyGroup>").Append(k_WindowsNewline);
headerBuilder.Append($" <BaseIntermediateOutputPath>{@"Temp\obj\$(Configuration)\$(MSBuildProjectName)".NormalizePathSeparators()}</BaseIntermediateOutputPath>").Append(k_WindowsNewline);
headerBuilder.Append(@" <IntermediateOutputPath>$(BaseIntermediateOutputPath)</IntermediateOutputPath>").Append(k_WindowsNewline);
headerBuilder.Append(@" </PropertyGroup>").Append(k_WindowsNewline);
// Supported capabilities
GetCapabilityBlock(headerBuilder, "Sdk.props", "Include", SupportedCapabilities);
headerBuilder.Append(@" <PropertyGroup>").Append(k_WindowsNewline);
headerBuilder.Append(@" <GenerateAssemblyInfo>false</GenerateAssemblyInfo>").Append(k_WindowsNewline);
headerBuilder.Append(@" <EnableDefaultItems>false</EnableDefaultItems>").Append(k_WindowsNewline);
@@ -76,7 +109,21 @@ namespace Microsoft.Unity.VisualStudio.Editor
internal override void GetProjectFooter(StringBuilder footerBuilder)
{
// Unsupported capabilities
GetCapabilityBlock(footerBuilder, "Sdk.targets", "Remove", UnsupportedCapabilities);
footerBuilder.Append("</Project>").Append(k_WindowsNewline);
}
internal static void GetCapabilityBlock(StringBuilder footerBuilder, string import, string attribute, string[] capabilities)
{
footerBuilder.Append($@" <Import Project=""{import}"" Sdk=""Microsoft.NET.Sdk"" />").Append(k_WindowsNewline);
footerBuilder.Append(@" <ItemGroup>").Append(k_WindowsNewline);
foreach (var capability in capabilities)
{
footerBuilder.Append($@" <ProjectCapability {attribute}=""{capability}"" />").Append(k_WindowsNewline);
}
footerBuilder.Append(@" </ItemGroup>").Append(k_WindowsNewline);
}
}
}

View File

@@ -66,13 +66,13 @@ namespace Microsoft.Unity.VisualStudio.Editor
private static bool IsCandidateForDiscovery(string path)
{
if (VisualStudioEditor.IsOSX)
return Directory.Exists(path) && Regex.IsMatch(path, ".*Code.*.app$", RegexOptions.IgnoreCase);
if (VisualStudioEditor.IsWindows)
return File.Exists(path) && Regex.IsMatch(path, ".*Code.*.exe$", RegexOptions.IgnoreCase);
#if UNITY_EDITOR_OSX
return Directory.Exists(path) && Regex.IsMatch(path, ".*Code.*.app$", RegexOptions.IgnoreCase);
#elif UNITY_EDITOR_WIN
return File.Exists(path) && Regex.IsMatch(path, ".*Code.*.exe$", RegexOptions.IgnoreCase);
#else
return File.Exists(path) && path.EndsWith("code", StringComparison.OrdinalIgnoreCase);
#endif
}
[Serializable]
@@ -99,17 +99,23 @@ namespace Microsoft.Unity.VisualStudio.Editor
{
var manifestBase = GetRealPath(editorPath);
if (VisualStudioEditor.IsWindows) // on Windows, editorPath is a file, resources as subdirectory
manifestBase = IOPath.GetDirectoryName(manifestBase);
else if (VisualStudioEditor.IsOSX) // on Mac, editorPath is a directory
manifestBase = IOPath.Combine(manifestBase, "Contents");
else // on Linux, editorPath is a file, in a bin sub-directory
manifestBase = Directory.GetParent(manifestBase)?.Parent?.FullName;
#if UNITY_EDITOR_WIN
// on Windows, editorPath is a file, resources as subdirectory
manifestBase = IOPath.GetDirectoryName(manifestBase);
#elif UNITY_EDITOR_OSX
// on Mac, editorPath is a directory
manifestBase = IOPath.Combine(manifestBase, "Contents");
#else
// on Linux, editorPath is a file, in a bin sub-directory
var parent = Directory.GetParent(manifestBase);
// but we can link to [vscode]/code or [vscode]/bin/code
manifestBase = parent?.Name == "bin" ? parent.Parent?.FullName : parent?.FullName;
#endif
if (manifestBase == null)
return false;
var manifestFullPath = IOPath.Combine(manifestBase, @"resources", "app", "package.json");
var manifestFullPath = IOPath.Combine(manifestBase, "resources", "app", "package.json");
if (File.Exists(manifestFullPath))
{
var manifest = JsonUtility.FromJson<VisualStudioCodeManifest>(File.ReadAllText(manifestFullPath));
@@ -138,30 +144,29 @@ namespace Microsoft.Unity.VisualStudio.Editor
{
var candidates = new List<string>();
if (VisualStudioEditor.IsWindows)
{
var localAppPath = IOPath.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Programs");
var programFiles = IOPath.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
#if UNITY_EDITOR_WIN
var localAppPath = IOPath.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Programs");
var programFiles = IOPath.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
foreach (var basePath in new[] {localAppPath, programFiles})
{
candidates.Add(IOPath.Combine(basePath, "Microsoft VS Code", "Code.exe"));
candidates.Add(IOPath.Combine(basePath, "Microsoft VS Code Insiders", "Code - Insiders.exe"));
}
}
else if (VisualStudioEditor.IsOSX)
foreach (var basePath in new[] {localAppPath, programFiles})
{
var appPath = IOPath.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
candidates.AddRange(Directory.EnumerateDirectories(appPath, "Visual Studio Code*.app"));
}
else
{
candidates.Add("/usr/bin/code");
candidates.Add("/bin/code");
candidates.Add("/usr/local/bin/code");
candidates.Add(IOPath.Combine(basePath, "Microsoft VS Code", "Code.exe"));
candidates.Add(IOPath.Combine(basePath, "Microsoft VS Code Insiders", "Code - Insiders.exe"));
}
#elif UNITY_EDITOR_OSX
var appPath = IOPath.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles));
candidates.AddRange(Directory.EnumerateDirectories(appPath, "Visual Studio Code*.app"));
#elif UNITY_EDITOR_LINUX
// Well known locations
candidates.Add("/usr/bin/code");
candidates.Add("/bin/code");
candidates.Add("/usr/local/bin/code");
foreach (var candidate in candidates)
// Preference ordered base directories relative to which desktop files should be searched
candidates.AddRange(GetXdgCandidates());
#endif
foreach (var candidate in candidates.Distinct())
{
if (TryDiscoverInstallation(candidate, out var installation))
yield return installation;
@@ -169,6 +174,41 @@ namespace Microsoft.Unity.VisualStudio.Editor
}
#if UNITY_EDITOR_LINUX
private static readonly Regex DesktopFileExecEntry = new Regex(@"Exec=(\S+)", RegexOptions.Singleline | RegexOptions.Compiled);
private static IEnumerable<string> GetXdgCandidates()
{
var envdirs = Environment.GetEnvironmentVariable("XDG_DATA_DIRS");
if (string.IsNullOrEmpty(envdirs))
yield break;
var dirs = envdirs.Split(':');
foreach(var dir in dirs)
{
Match match = null;
try
{
var desktopFile = IOPath.Combine(dir, "applications/code.desktop");
if (!File.Exists(desktopFile))
continue;
var content = File.ReadAllText(desktopFile);
match = DesktopFileExecEntry.Match(content);
}
catch
{
// do not fail if we cannot read desktop file
}
if (match == null || !match.Success)
continue;
yield return match.Groups[1].Value;
break;
}
}
[System.Runtime.InteropServices.DllImport ("libc")]
private static extern int readlink(string path, byte[] buffer, int buflen);
@@ -475,13 +515,14 @@ namespace Microsoft.Unity.VisualStudio.Editor
private static ProcessStartInfo ProcessStartInfoFor(string application, string arguments)
{
if (!VisualStudioEditor.IsOSX)
return ProcessRunner.ProcessStartInfoFor(application, arguments, redirect: false);
#if UNITY_EDITOR_OSX
// wrap with built-in OSX open feature
arguments = $"-n \"{application}\" --args {arguments}";
application = "open";
return ProcessRunner.ProcessStartInfoFor(application, arguments, redirect:false, shell: true);
#else
return ProcessRunner.ProcessStartInfoFor(application, arguments, redirect: false);
#endif
}
public static void Initialize()

View File

@@ -21,9 +21,6 @@ namespace Microsoft.Unity.VisualStudio.Editor
[InitializeOnLoad]
public class VisualStudioEditor : IExternalCodeEditor
{
internal static bool IsOSX => Application.platform == RuntimePlatform.OSXEditor;
internal static bool IsWindows => !IsOSX && Path.DirectorySeparatorChar == FileUtility.WinSeparator && Environment.NewLine == "\r\n";
CodeEditor.Installation[] IExternalCodeEditor.Installations => _discoverInstallations
.Result
.Values

View File

@@ -3,6 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
#if UNITY_EDITOR_OSX
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -101,7 +103,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
private static bool IsCandidateForDiscovery(string path)
{
return Directory.Exists(path) && VisualStudioEditor.IsOSX && Regex.IsMatch(path, "Visual\\s?Studio(?!.*Code.*).*.app$", RegexOptions.IgnoreCase);
return Directory.Exists(path) && Regex.IsMatch(path, "Visual\\s?Studio(?!.*Code.*).*.app$", RegexOptions.IgnoreCase);
}
public static bool TryDiscoverInstallation(string editorPath, out IVisualStudioInstallation installation)
@@ -144,9 +146,6 @@ namespace Microsoft.Unity.VisualStudio.Editor
public static IEnumerable<IVisualStudioInstallation> GetVisualStudioInstallations()
{
if (!VisualStudioEditor.IsOSX)
yield break;
var candidates = Directory.EnumerateDirectories("/Applications", "*.app");
foreach (var candidate in candidates)
{
@@ -178,3 +177,5 @@ namespace Microsoft.Unity.VisualStudio.Editor
}
}
}
#endif

View File

@@ -3,6 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
#if UNITY_EDITOR_WIN
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -126,7 +128,7 @@ namespace Microsoft.Unity.VisualStudio.Editor
private static bool IsCandidateForDiscovery(string path)
{
return File.Exists(path) && VisualStudioEditor.IsWindows && Regex.IsMatch(path, "devenv.exe$", RegexOptions.IgnoreCase);
return File.Exists(path) && Regex.IsMatch(path, "devenv.exe$", RegexOptions.IgnoreCase);
}
public static bool TryDiscoverInstallation(string editorPath, out IVisualStudioInstallation installation)
@@ -169,9 +171,6 @@ namespace Microsoft.Unity.VisualStudio.Editor
public static IEnumerable<IVisualStudioInstallation> GetVisualStudioInstallations()
{
if (!VisualStudioEditor.IsWindows)
yield break;
foreach (var installation in QueryVsWhere())
yield return installation;
}
@@ -373,8 +372,9 @@ namespace Microsoft.Unity.VisualStudio.Editor
public static void Initialize()
{
if (VisualStudioEditor.IsWindows)
_vsWherePath = FileUtility.GetPackageAssetFullPath("Editor", "VSWhere", "vswhere.exe");
_vsWherePath = FileUtility.GetPackageAssetFullPath("Editor", "VSWhere", "vswhere.exe");
}
}
}
#endif

View File

@@ -106,10 +106,9 @@ namespace Microsoft.Unity.VisualStudio.Editor
private static void RunOnShutdown(Action action)
{
// Mono on OSX has all kinds of quirks on AppDomain shutdown
if (!VisualStudioEditor.IsWindows)
return;
#if UNITY_EDITOR_WIN
AppDomain.CurrentDomain.DomainUnload += (_, __) => action();
#endif
}
private static int DebuggingPort()