public void EmbedAllSources() { var vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.EmbeddedFiles = MSBuildUtil.CreateTaskItems(@"test.vb", @"test.txt"); vbc.EmbedAllSources = true; Assert.Equal(@"/optionstrict:custom /out:test.exe /embed /embed:test.vb /embed:test.txt test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.EmbedAllSources = true; Assert.Equal(@"/optionstrict:custom /out:test.exe /embed test.vb", vbc.GenerateResponseFileContents()); }
public void EmptyCscToolPath() { var csc = new Csc(); csc.ToolPath = ""; csc.ToolExe = Path.Combine("path", "to", "custom_csc"); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("", csc.GenerateCommandLine()); Assert.Equal(Path.Combine("path", "to", "custom_csc"), csc.GeneratePathToTool()); csc = new Csc(); csc.ToolExe = Path.Combine("path", "to", "custom_csc"); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("", csc.GenerateCommandLine()); Assert.Equal(Path.Combine("path", "to", "custom_csc"), csc.GeneratePathToTool()); }
public void EmbedAllSources() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.EmbeddedFiles = MSBuildUtil.CreateTaskItems(@"test.cs", @"test.txt"); csc.EmbedAllSources = true; Assert.Equal(@"/out:test.exe /embed /embed:test.cs /embed:test.txt test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.EmbedAllSources = true; Assert.Equal(@"/out:test.exe /embed test.cs", csc.GenerateResponseFileContents()); }
public void PublicSignFlag() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.PublicSign = true; Assert.Equal("/out:test.exe /publicsign+ test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.PublicSign = false; Assert.Equal("/out:test.exe /publicsign- test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents()); }
public void DeterministicFlag() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.Deterministic = true; Assert.Equal("/out:test.exe /deterministic+ test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.Deterministic = false; Assert.Equal("/out:test.exe /deterministic- test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents()); }
public void EmptyCscToolExe() { var csc = new Csc(); csc.ToolPath = Path.Combine("path", "to", "custom_csc"); csc.ToolExe = ""; csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("", csc.GenerateCommandLine()); // StartsWith because it can be csc.exe or csc.dll Assert.StartsWith(Path.Combine("path", "to", "custom_csc", "csc."), csc.GeneratePathToTool()); csc = new Csc(); csc.ToolPath = Path.Combine("path", "to", "custom_csc"); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("", csc.GenerateCommandLine()); Assert.StartsWith(Path.Combine("path", "to", "custom_csc", "csc."), csc.GeneratePathToTool()); }
public void Features() { Action <string> test = (s) => { var csc = new Csc(); csc.Features = s; csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("/out:test.exe /features:a /features:b test.cs", csc.GenerateResponseFileContents()); }; test("a;b"); test("a,b"); test("a b"); test(",a;b "); test(";a;;b;"); test(",a,,b,"); }
public void DeterministicFlag() { var vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.Deterministic = true; Assert.Equal("/optionstrict:custom /out:test.exe /deterministic+ test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.Deterministic = false; Assert.Equal("/optionstrict:custom /out:test.exe /deterministic- test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); Assert.Equal("/optionstrict:custom /out:test.exe test.vb", vbc.GenerateResponseFileContents()); }
public void SkipAnalyzersFlag() { var vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.SkipAnalyzers = true; Assert.Equal("/optionstrict:custom /out:test.exe /skipanalyzers+ test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.SkipAnalyzers = false; Assert.Equal("/optionstrict:custom /out:test.exe /skipanalyzers- test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); Assert.Equal("/optionstrict:custom /out:test.exe test.vb", vbc.GenerateResponseFileContents()); }
public void ChecksumAlgorithmOption() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.ChecksumAlgorithm = "sha256"; Assert.Equal("/out:test.exe /checksumalgorithm:sha256 test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.ChecksumAlgorithm = null; Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.ChecksumAlgorithm = ""; Assert.Equal("/out:test.exe /checksumalgorithm: test.cs", csc.GenerateResponseFileContents()); }
public void Features() { Action <string> test = (s) => { var vbc = new Vbc(); vbc.Features = s; vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); Assert.Equal(@"/optionstrict:custom /out:test.exe /features:a /features:b test.vb", vbc.GenerateResponseFileContents()); }; test("a;b"); test("a,b"); test("a b"); test(",a;b "); test(";a;;b;"); test(",a,,b,"); }
public void SkipAnalyzersFlag() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.SkipAnalyzers = true; Assert.Equal("/out:test.exe /skipanalyzers+ test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.SkipAnalyzers = false; Assert.Equal("/out:test.exe /skipanalyzers- test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents()); }
public void DefineConstantsSimple() { Action <string> test = (s) => { var csc = new Csc(); csc.DefineConstants = s; csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal( "/define:D1;D2 /out:test.exe test.cs", csc.GenerateResponseFileContents() ); }; test("D1;D2"); test("D1,D2"); test("D1 D2"); }
public void DefineConstantsSimple() { Action <string> test = (s) => { var vbc = new Vbc(); vbc.DefineConstants = s; vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); Assert.Equal( $@"/optionstrict:custom /define:""{s}"" /out:test.exe test.vb", vbc.GenerateResponseFileContents() ); }; test("D1;D2"); test("D1,D2"); test("D1 D2"); }
public void PublicSignFlag() { var vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.PublicSign = true; Assert.Equal("/optionstrict:custom /out:test.exe /publicsign+ test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.PublicSign = false; Assert.Equal("/optionstrict:custom /out:test.exe /publicsign- test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); Assert.Equal("/optionstrict:custom /out:test.exe test.vb", vbc.GenerateResponseFileContents()); }
public void ChecksumAlgorithmOption() { var vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.ChecksumAlgorithm = "sha256"; Assert.Equal("/optionstrict:custom /out:test.exe /checksumalgorithm:sha256 test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.ChecksumAlgorithm = null; Assert.Equal("/optionstrict:custom /out:test.exe test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.ChecksumAlgorithm = ""; Assert.Equal("/optionstrict:custom /out:test.exe /checksumalgorithm: test.vb", vbc.GenerateResponseFileContents()); }
public void PathMapOption() { var vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.PathMap = "K1=V1,K2=V2"; Assert.Equal( "/optionstrict:custom /pathmap:\"K1=V1,K2=V2\" /out:test.exe test.vb", vbc.GenerateResponseFileContents() ); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); Assert.Equal( "/optionstrict:custom /out:test.exe test.vb", vbc.GenerateResponseFileContents() ); }
public void EditorConfig() { var vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.AnalyzerConfigFiles = MSBuildUtil.CreateTaskItems(".editorconfig"); Assert.Equal(@"/optionstrict:custom /out:test.exe /analyzerconfig:.editorconfig test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb", "subdir\\test.vb"); vbc.AnalyzerConfigFiles = MSBuildUtil.CreateTaskItems(".editorconfig", "subdir\\.editorconfig"); Assert.Equal(@$ "/optionstrict:custom /out:test.exe /analyzerconfig:.editorconfig /analyzerconfig:subdir\.editorconfig test.vb subdir{Path.DirectorySeparatorChar}test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.AnalyzerConfigFiles = MSBuildUtil.CreateTaskItems("..\\.editorconfig", "sub dir\\.editorconfig"); Assert.Equal(@"/optionstrict:custom /out:test.exe /analyzerconfig:..\.editorconfig /analyzerconfig:""sub dir\.editorconfig"" test.vb", vbc.GenerateResponseFileContents()); }
public void EditorConfig() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.AnalyzerConfigFiles = MSBuildUtil.CreateTaskItems(".editorconfig"); Assert.Equal(@"/out:test.exe /analyzerconfig:.editorconfig test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs", "subdir\\test.cs"); csc.AnalyzerConfigFiles = MSBuildUtil.CreateTaskItems(".editorconfig", "subdir\\.editorconfig"); Assert.Equal(@"/out:test.exe /analyzerconfig:.editorconfig /analyzerconfig:subdir\.editorconfig test.cs subdir\test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.AnalyzerConfigFiles = MSBuildUtil.CreateTaskItems("..\\.editorconfig", "sub dir\\.editorconfig"); Assert.Equal(@"/out:test.exe /analyzerconfig:..\.editorconfig /analyzerconfig:""sub dir\.editorconfig"" test.cs", csc.GenerateResponseFileContents()); }
public void SharedCompilationId() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.UseSharedCompilation = true; csc.SharedCompilationId = "testPipeName"; Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.UseSharedCompilation = false; csc.SharedCompilationId = "testPipeName"; Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.SharedCompilationId = "testPipeName"; Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents()); }
public void RuntimeMetadataVersionFlag() { var vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.RuntimeMetadataVersion = "v1234"; Assert.Equal( "/optionstrict:custom /out:test.exe /runtimemetadataversion:v1234 test.vb", vbc.GenerateResponseFileContents() ); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.RuntimeMetadataVersion = null; Assert.Equal( "/optionstrict:custom /out:test.exe test.vb", vbc.GenerateResponseFileContents() ); }
public void DebugType() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = "full"; Assert.Equal("/debug:full /out:test.exe test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = "pdbonly"; Assert.Equal( "/debug:pdbonly /out:test.exe test.cs", csc.GenerateResponseFileContents() ); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = "portable"; Assert.Equal( "/debug:portable /out:test.exe test.cs", csc.GenerateResponseFileContents() ); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = "embedded"; Assert.Equal( "/debug:embedded /out:test.exe test.cs", csc.GenerateResponseFileContents() ); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = null; Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = ""; Assert.Equal("/debug: /out:test.exe test.cs", csc.GenerateResponseFileContents()); }
public void SharedCompilationId() { var vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.UseSharedCompilation = true; vbc.SharedCompilationId = "testPipeName"; Assert.Equal("/optionstrict:custom /out:test.exe test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.UseSharedCompilation = false; vbc.SharedCompilationId = "testPipeName"; Assert.Equal("/optionstrict:custom /out:test.exe test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.SharedCompilationId = "testPipeName"; Assert.Equal("/optionstrict:custom /out:test.exe test.vb", vbc.GenerateResponseFileContents()); }
public void SourceLink() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = "portable"; csc.SourceLink = @"C:\x y\z.json"; Assert.Equal(@"/debug:portable /out:test.exe /sourcelink:""C:\x y\z.json"" test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = "portable"; csc.SourceLink = null; Assert.Equal(@"/debug:portable /out:test.exe test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = "portable"; csc.SourceLink = ""; Assert.Equal(@"/debug:portable /out:test.exe /sourcelink: test.cs", csc.GenerateResponseFileContents()); }
public void SourceLink() { var vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.DebugType = "portable"; vbc.SourceLink = @"C:\x y\z.json"; Assert.Equal(@"/optionstrict:custom /debug:portable /out:test.exe /sourcelink:""C:\x y\z.json"" test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.DebugType = "portable"; vbc.SourceLink = null; Assert.Equal(@"/optionstrict:custom /debug:portable /out:test.exe test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.DebugType = "portable"; vbc.SourceLink = ""; Assert.Equal(@"/optionstrict:custom /debug:portable /out:test.exe /sourcelink: test.vb", vbc.GenerateResponseFileContents()); }
public void Embed() { var vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.DebugType = "portable"; vbc.EmbeddedFiles = MSBuildUtil.CreateTaskItems(@"test.vb", @"test.txt"); Assert.Equal(@"/optionstrict:custom /debug:portable /out:test.exe /embed:test.vb /embed:test.txt test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.DebugType = "portable"; vbc.EmbeddedFiles = MSBuildUtil.CreateTaskItems(@"C:\x y\z.json"); Assert.Equal(@"/optionstrict:custom /debug:portable /out:test.exe /embed:""C:\x y\z.json"" test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.DebugType = "portable"; vbc.EmbeddedFiles = null; Assert.Equal(@"/optionstrict:custom /debug:portable /out:test.exe test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("test.vb"); vbc.DebugType = "full"; vbc.EmbeddedFiles = MSBuildUtil.CreateTaskItems(); Assert.Equal(@"/optionstrict:custom /debug:full /out:test.exe test.vb", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("a;b.vb"); vbc.DebugType = "full"; vbc.EmbeddedFiles = MSBuildUtil.CreateTaskItems("a;b.vb"); Assert.Equal(@"/optionstrict:custom /debug:full /out:""a;b.exe"" /embed:""a;b.vb"" ""a;b.vb""", vbc.GenerateResponseFileContents()); vbc = new Vbc(); vbc.Sources = MSBuildUtil.CreateTaskItems("a, b.vb"); vbc.DebugType = "full"; vbc.EmbeddedFiles = MSBuildUtil.CreateTaskItems("a, b.vb"); Assert.Equal(@"/optionstrict:custom /debug:full /out:""a, b.exe"" /embed:""a, b.vb"" ""a, b.vb""", vbc.GenerateResponseFileContents()); }
public void Embed() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = "portable"; csc.EmbeddedFiles = MSBuildUtil.CreateTaskItems(@"test.cs", @"test.txt"); Assert.Equal( @"/debug:portable /out:test.exe /embed:test.cs /embed:test.txt test.cs", csc.GenerateResponseFileContents() ); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = "portable"; csc.EmbeddedFiles = MSBuildUtil.CreateTaskItems(@"C:\x y\z.json"); Assert.Equal( @"/debug:portable /out:test.exe /embed:""C:\x y\z.json"" test.cs", csc.GenerateResponseFileContents() ); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = "portable"; csc.EmbeddedFiles = null; Assert.Equal( @"/debug:portable /out:test.exe test.cs", csc.GenerateResponseFileContents() ); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.DebugType = "full"; csc.EmbeddedFiles = MSBuildUtil.CreateTaskItems(); Assert.Equal(@"/debug:full /out:test.exe test.cs", csc.GenerateResponseFileContents()); }
public void SingleSource() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents()); }