public void Write() { TemplatedWriter propsWriter = new TemplatedWriter(propsTemplateFile) .Write(ProjectGuidToken, Guid) .Write(MSBuildForUnityVersionToken, MSBuildForUnityVersion.ToString()); foreach (ProjectReference projectReference in References) { TemplatedWriter referenceWriter = propsWriter.CreateWriterFor(ProjectReferenceTemplate) .Write(ProjectReferenceTemplate_ReferenceToken, projectReference.ReferencePath.LocalPath) .Write(ProjectReferenceTemplate_ConditionToken, projectReference.Condition ?? string.Empty); if (projectReference.IsGenerated) { // Creating this is sufficient for the template to be included in the output referenceWriter.CreateWriterFor(PrivateReferenceTemplate); } } propsWriter.Export(propsExportPath); // Don't overwrite primary export path, as that is the file that is allowed to be edited if (!File.Exists(primaryExportPath.FullName)) { new TemplatedWriter(primaryTemplateFile).Export(primaryExportPath); } new TemplatedWriter(targetsTemplateFile).Export(targetsExportPath); }
public void Write() { TemplatedWriter writer = new TemplatedWriter(solutionFileTemplate); // Validate configuration, to ensure the solution has all of the children mapping ValidateProjectConfiguration(); // Write out Project Data foreach (Guid projectGuid in GetOrderedProjects()) { WriteProject(writer, projectGuid, Projects[projectGuid]); } SortedDictionary <Guid, Guid> childToParentMapping = new SortedDictionary <Guid, Guid>(); // Write folders foreach (KeyValuePair <Guid, SolutionFolder> folder in Folders) { writer.CreateWriterFor(FolderTemplate) .Write(FolderTemplate_GuidToken, folder.Key) .Write(FolderTemplate_NameToken, folder.Value.Name); foreach (Guid child in folder.Value.Children) { childToParentMapping[child] = folder.Key; } } // Write the sorted nested projects foreach (KeyValuePair <Guid, Guid> mapping in childToParentMapping) { writer.CreateWriterFor(FolderNestedTemplate) .Write(FolderNestedTemplate_ChildGuidToken, mapping.Key) .Write(FolderNestedTemplate_FolderGuidToken, mapping.Value); } // Write Config mappings foreach (ConfigurationPlatformPair configPair in ConfigurationPlatforms) { writer.CreateWriterFor(ConfigurationPlatformTemplate) .Write(ConfigurationPlatformTemplate_ConfigurationToken, configPair.Configuration) .Write(ConfigurationPlatformTemplate_PlatformToken, configPair.Platform); } // Write generated items WriteDictionarySet(writer, GeneratedItems.ToDictionary(guid => $"{{{guid}}}", t => MSB4UGeneratedNote), SolutionNotesTemplate); // Write all the known dictionary sections WriteDictionarySet(writer, Properties, SolutionPropertiesTemplate); WriteDictionarySet(writer, Notes, SolutionNotesTemplate); WriteDictionarySet(writer, ExtensibilityGlobals, ExtensibilityGlobalsTemplate); // Write Extra sections WriteExtraSections(writer, AdditionalSections, KnownSolutionSectionNames, ExtraGlobalSectionTemplate, t => t == SectionType.PreSection ? "preSolution" : "postSolution"); writer.Export(solutionOutputPath); }
public void Write() { TemplatedWriter writer = new TemplatedWriter(fileTemplate); writer.Write(MSBuildForUnityVersionToken, MSBuildForUnityVersion.ToString()); writer.Write(UnityMajorVersionToken, UnityMajorVersion); writer.Write(UnityMinorVersionToken, UnityMinorVersion); writer.Write(UnityEditorInstallPathToken, UnityEditorInstallPath.FullName); writer.Write(CurrentUnityPlatformToken, CurrentUnityPlatform); writer.Write(CurrentTargetFrameworkToken, CurrentTargetFramework); writer.Write(UnityProjectAssetsDirectoryToken, UnityProjectAssetsDirectory.FullName); writer.Write(GeneratedOutputDirectoryToken, GeneratedProjectOutputPath.FullName); writer.Export(exportPath); }
public void Write() { TemplatedWriter writer = new TemplatedWriter(fileTemplate); writer.Write(TargetFrameworkToken, TargetFramework, optional: true); writer.Write(DefineConstantsToken, DefineConstants); writer.Write(AssemblySearchPathsToken, AssemblySearchPaths); foreach (KeyValuePair <string, Uri> reference in References) { TemplatedWriter subTemplateWriter = writer.CreateWriterFor(CommonReferenceSubTemplate); subTemplateWriter.Write(CommonReferencesSubTemplateReferenceToken, reference.Key); subTemplateWriter.Write(CommonReferencesSubTemplateHintPathToken, reference.Value.LocalPath); } OnWrite(writer); writer.Export(exportPath); }
public void Write() { TemplatedWriter propsWriter = new TemplatedWriter(propsTemplateFile) .Write(ProjectGuidToken, Guid) .Write(ProjectNameToken, ProjectName) .Write(AllowUnsafeToken, AllowUnsafe.ToString()) .Write(LanguageVersionToken, LanguageVersion) .Write(IsEditorOnlyProjectToken, IsEditorOnlyProject.ToString()) .Write(DefaultPlatformToken, DefaultPlatform) .Write(SupportedPlatformsToken, SupportedPlatforms) .Write(AssemblySearchPathsToken, AssemblySearchPaths) .Write(SourceIncludePathToken, SourceIncludePath.FullName); foreach (DirectoryInfo excludePath in SourceExcludePaths) { propsWriter.CreateWriterFor(SourceExcludeTemplate) .Write(SourceExcludeTemplate_ExcludePathToken, excludePath.FullName); } foreach (KeyValuePair <UnityConfigurationType, HashSet <PluginReference> > configSet in PluginReferences) { TemplatedWriter setWriter = propsWriter.CreateWriterFor(PluginReferenceTemplateSet) .Write(ReferenceTemplateSet_ConfigurationToken, configSet.Key.ToString()); foreach (PluginReference pluginReference in configSet.Value) { setWriter.CreateWriterFor(PluginReferenceTemplate) .Write(PluginReferenceTemplate_ReferenceToken, pluginReference.ReferenceName) .Write(PluginReferenceTemplate_ConditionToken, pluginReference.Condition) .Write(PluginReferenceTemplate_HintPathToken, pluginReference.HintPath.LocalPath); } } foreach (KeyValuePair <UnityConfigurationType, HashSet <ProjectReference> > configSet in ProjectReferences) { TemplatedWriter setWriter = propsWriter.CreateWriterFor(ProjectReferenceTemplateSet) .Write(ReferenceTemplateSet_ConfigurationToken, configSet.Key.ToString()); foreach (ProjectReference pluginReference in configSet.Value) { setWriter.CreateWriterFor(ProjectReferenceTemplate) .Write(PluginReferenceTemplate_ReferenceToken, pluginReference.ReferencePath.LocalPath) .Write(PluginReferenceTemplate_ConditionToken, pluginReference.Condition); } } propsWriter.Export(propsExportPath); // Write the targets part TemplatedWriter targetsWriter = new TemplatedWriter(targetsTemplateFile); foreach (ConfigurationPlatformPair pair in SupportedBuildPlatforms) { targetsWriter.CreateWriterFor(SupportedPlatformBuildTemplate) .Write(SupportedPlatformBuildTemplate_ConfigurationToken, pair.Configuration) .Write(SupportedPlatformBuildTemplate_PlatformToken, pair.Platform); } targetsWriter.Export(targetsExportPath); // Don't overwrite primary export path, as that is the file that is allowed to be edited if (IsGenerated) { new TemplatedWriter(primaryTemplateFile).Export(primaryExportPath); File.SetAttributes(primaryExportPath.FullName, FileAttributes.ReadOnly); } else if (!File.Exists(primaryExportPath.FullName)) { new TemplatedWriter(primaryTemplateFile).Export(primaryExportPath); } }