/// <summary> /// Writes the build specification into the path (see <see cref="RelativePath" />) relative to <paramref name="directory" />. /// </summary> /// <param name="directory">Directory for writing the build specification.</param> public void Write(string directory, DsTestWriter testWriter) { Contract.Requires(!string.IsNullOrWhiteSpace(directory)); var fullPath = Path.Combine(directory, RelativePath); testWriter.WriteFile(fullPath, Spec); if (IsPackage) { WriteAsPackage(directory, testWriter); } }
/// <summary> /// Writes the configuration into <paramref name="directory" />. /// </summary> /// <param name="directory">Directory for writing the configuration.</param> public void Write(string directory, DsTestWriter testWriter) { Contract.Requires(!string.IsNullOrWhiteSpace(directory)); for (int i = 0; i < m_buildSpecWriters.Count; ++i) { m_buildSpecWriters[i].Write(directory, testWriter); } var fullPath = Path.Combine( directory, PrimaryConfigurationFileName); testWriter.WriteFile(fullPath, m_configContent ?? ToString()); }
private void WriteAsPackage(string directory, DsTestWriter testWriter) { Contract.Requires(!string.IsNullOrWhiteSpace(directory)); Contract.Requires(!string.IsNullOrWhiteSpace(m_name)); var builder = new StringBuilder(); builder.AppendLine("module({"); builder.AppendLine(" name: \"" + m_name + "\","); if (m_implicitReferenceSemantics) { builder.AppendLine(" nameResolutionSemantics: NameResolutionSemantics.implicitProjectReferences,"); } builder.AppendLine("});"); var fullPath = Path.Combine(directory, Path.ChangeExtension(RelativePath, Names.DotConfigDotDscExtension)); testWriter.WriteFile(fullPath, builder.ToString()); }
/// <nodoc /> public static DsTestWriter Create(string sourceRoot, IEnumerable <BuildSpec> buildSpecs, IMutableFileSystem fileSystem) { // Putting source into the nested folder in order to avoid file access violation when writing package files outside the source cone. var testWriter = new DsTestWriter(fileSystem.GetPathTable(), fileSystem, sourceRoot); foreach (var spec in buildSpecs) { if (spec.FileName == Names.ConfigDsc) { testWriter.ConfigWriter.SetConfigContent(spec.Content); testWriter.ConfigWriter.UseLegacyConfigExtension(); } else if (spec.FileName == Names.ConfigBc) { testWriter.ConfigWriter.SetConfigContent(spec.Content); } else { testWriter.ConfigWriter.AddBuildSpec(spec.FileName, spec.Content); } } return(testWriter); }