public virtual FileInfo WriteSlnFile(Sln solution, string writeInDirectory) { var outputFile = new FileInfo(GetOutputFilePath(writeInDirectory, solution)); if (outputFile.Directory != null && !outputFile.Directory.Exists) { outputFile.Directory.Create(); } var renderer = new SlnFileRenderer(solution); var fileContents = renderer.Render(); if (outputFile.Exists && ContentsUnmodified(outputFile, fileContents)) { Log.Info("Solution file is unmodified from previous generation."); return(outputFile); } using (var writer = new StreamWriter(outputFile.Open(FileMode.Create))) { writer.Write(fileContents); } Log.Info("Solution file written to " + outputFile.FullName); return(outputFile); }
public virtual FileInfo WriteSlnFile(Sln solution, string writeInDirectory) { var outputFile = new FileInfo(GetOutputFilePath(writeInDirectory, solution)); if (!outputFile.Directory.Exists) { outputFile.Directory.Create(); } var renderer = new SlnFileRenderer(solution); var fileContents = renderer.Render(); if (outputFile.Exists && ContentsUnmodified(outputFile, fileContents)) { Log.Info("Solution file is unmodified from previous generation."); return outputFile; } using (var writer = new StreamWriter(outputFile.Open(FileMode.Create))) { writer.Write(fileContents); } Log.Info("Solution file written to " + outputFile.FullName); return outputFile; }
private void TestRender() { renderer = new SlnFileRenderer(solution); string actualContents = renderer.Render().Replace("\r\n", "\n").Replace("\n\n", "\n"); string expectedContents = SampleFileHelper.GetSlnFileContents(solution.Name).Replace("\r\n", "\n").Replace("\n\n", "\n"); Assert.That(actualContents, Is.EqualTo(expectedContents)); }