You've already forked com.unity.ide.cursor
mirror of
https://github.com/boxqkrtm/com.unity.ide.cursor.git
synced 2026-05-16 07:20:06 +00:00
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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user