/*--------------------------------------------------------------------------------------------- * Copyright (c) Unity Technologies. * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ using System.Text; using UnityEditor.Compilation; 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) { } public LegacyStyleProjectGeneration(string tempDirectory) : base(tempDirectory) { } public LegacyStyleProjectGeneration() { } internal override void GetProjectHeader(ProjectProperties properties, out StringBuilder headerBuilder) { headerBuilder = new StringBuilder(); //Header headerBuilder.Append(@"").Append(k_WindowsNewline); headerBuilder.Append($@"").Append(k_WindowsNewline); headerBuilder.Append(@" ").Append(k_WindowsNewline); headerBuilder.Append(@" ").Append(k_WindowsNewline); headerBuilder.Append(@" ").Append(properties.LangVersion).Append(@"").Append(k_WindowsNewline); headerBuilder.Append(@" ").Append(k_WindowsNewline); headerBuilder.Append(@" ").Append(k_WindowsNewline); headerBuilder.Append(@" Debug").Append(k_WindowsNewline); headerBuilder.Append(@" AnyCPU").Append(k_WindowsNewline); headerBuilder.Append(@" 10.0.20506").Append(k_WindowsNewline); headerBuilder.Append(@" 2.0").Append(k_WindowsNewline); headerBuilder.Append(@" ").Append(properties.RootNamespace).Append(@"").Append(k_WindowsNewline); headerBuilder.Append(@" {").Append(properties.ProjectGuid).Append(@"}").Append(k_WindowsNewline); headerBuilder.Append(@" Library").Append(k_WindowsNewline); headerBuilder.Append(@" Properties").Append(k_WindowsNewline); headerBuilder.Append(@" ").Append(properties.AssemblyName).Append(@"").Append(k_WindowsNewline); // In the end, given we use NoConfig/NoStdLib (see below), hardcoding the target framework version with the legacy format will have no impact, even when targeting netstandard/net48 from Unity. // And VSTU/Unity Game workload has a dependency towards net471 reference assemblies, so IDE will not complain that this specific SDK is not available. // Unity already selected proper API surface through referenced DLLs for us. headerBuilder.Append(@" v4.7.1").Append(k_WindowsNewline); headerBuilder.Append(@" 512").Append(k_WindowsNewline); headerBuilder.Append(@" .").Append(k_WindowsNewline); headerBuilder.Append(@" ").Append(k_WindowsNewline); GetProjectHeaderConfigurations(properties, headerBuilder); // Explicit references headerBuilder.Append(@" ").Append(k_WindowsNewline); headerBuilder.Append(@" true").Append(k_WindowsNewline); headerBuilder.Append(@" true").Append(k_WindowsNewline); headerBuilder.Append(@" false").Append(k_WindowsNewline); headerBuilder.Append(@" false").Append(k_WindowsNewline); headerBuilder.Append(@" false").Append(k_WindowsNewline); headerBuilder.Append(@" ").Append(k_WindowsNewline); GetProjectHeaderVstuFlavoring(properties, headerBuilder); GetProjectHeaderAnalyzers(properties, headerBuilder); } internal override void AppendProjectReference(Assembly assembly, Assembly reference, StringBuilder projectBuilder) { // If the current assembly is a Player project, we want to project-reference the corresponding Player project var referenceName = m_AssemblyNameProvider.GetAssemblyName(assembly.outputPath, reference.name); projectBuilder.Append(@" ").Append(k_WindowsNewline); projectBuilder.Append(" {").Append(ProjectGuid(referenceName)).Append("}").Append(k_WindowsNewline); projectBuilder.Append(" ").Append(referenceName).Append("").Append(k_WindowsNewline); projectBuilder.Append(" ").Append(k_WindowsNewline); } internal override void GetProjectFooter(StringBuilder footerBuilder) { footerBuilder.Append(string.Join(k_WindowsNewline, $" ", @" ", @" ", @"", @"")); } } }