public void TargetTypeDll() { var csc = new Csc(); csc.TargetType = "library"; csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("/out:test.dll /target:library test.cs", csc.GenerateResponseFileContents()); }
public void OutputAssembly() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.OutputAssembly = MSBuildUtil.CreateTaskItem("x.exe"); Assert.Equal("/out:x.exe test.cs", csc.GenerateResponseFileContents()); }
public void TargetTypeBad() { var csc = new Csc(); csc.TargetType = "bad"; csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("/out:test.exe /target:bad test.cs", csc.GenerateResponseFileContents()); }
protected override void AddResponseFileCommands(CommandLineBuilderExtension commandLine) { commandLine.AppendSwitchIfNotNull("/lib:", AdditionalLibPaths, ","); commandLine.AppendSwitchIfNotNull("/loadpaths:", AdditionalLoadPaths, ","); commandLine.AppendSwitchIfNotNull("/imports:", Imports, ";"); Csc.AddReferencesToCommandLine(commandLine, References, isInteractive: true); base.AddResponseFileCommands(commandLine); }
public void PathMapOption() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.PathMap = "K1=V1,K2=V2"; Assert.Equal("/pathmap:\"K1=V1,K2=V2\" /out:test.exe test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("/out:test.exe test.cs", csc.GenerateResponseFileContents()); }
public void RuntimeMetadataVersionFlag() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.RuntimeMetadataVersion = "v1234"; Assert.Equal("/out:test.exe /runtimemetadataversion:v1234 test.cs", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); csc.RuntimeMetadataVersion = null; 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 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 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 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 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 InstrumentTestNamesFlag() { var csc = new Csc(); csc.Instrument = null; Assert.Equal(string.Empty, csc.GenerateResponseFileContents()); csc = new Csc(); csc.Instrument = "TestCoverage"; Assert.Equal("/instrument:TestCoverage", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Instrument = "TestCoverage,Mumble"; Assert.Equal("/instrument:TestCoverage,Mumble", csc.GenerateResponseFileContents()); csc = new Csc(); csc.Instrument = "TestCoverage,Mumble;Stumble"; Assert.Equal("/instrument:TestCoverage,Mumble,Stumble", csc.GenerateResponseFileContents()); }
public void InstrumentTestNamesFlag() { var csc = new Csc(); csc.Instrument = "Instrument.This.Flag"; Assert.Equal("/instrument:Instrument.This.Flag", csc.GenerateResponseFileContents()); }
public void ExecuteCscBuildTaskWithServer() { var csc = new Csc(); var srcFile = _tempDirectory.CreateFile(s_helloWorldSrcCs[0].Key).WriteAllText(s_helloWorldSrcCs[0].Value).Path; var exeFile = Path.Combine(_tempDirectory.Path, "hello.exe"); var engine = new MockEngine(); csc.BuildEngine = engine; csc.Sources = new[] { new Build.Utilities.TaskItem(srcFile) }; csc.NoLogo = true; csc.OutputAssembly = new Build.Utilities.TaskItem(exeFile); csc.ToolPath = ""; csc.ToolExe = ""; csc.UseSharedCompilation = true; csc.Execute(); Assert.Equal(0, csc.ExitCode); Assert.Equal(string.Empty, engine.Warnings); Assert.Equal(string.Empty, engine.Errors); Assert.True(File.Exists(exeFile)); var result = ProcessLauncher.Run(exeFile, ""); Assert.Equal(0, result.ExitCode); Assert.Equal("Hello, world.", result.Output.Trim()); }
public void FeaturesEmpty() { foreach (var cur in new[] { "", null }) { var csc = new Csc(); csc.Features = cur; csc.Sources = MSBuildUtil.CreateTaskItems("test.cs"); Assert.Equal("/out:test.exe test.cs", csc.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 = "portable"; csc.EmbeddedFiles = MSBuildUtil.CreateTaskItems(); Assert.Equal(@"/debug:portable /out:test.exe test.cs", csc.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 MultipleSourceFiles() { var csc = new Csc(); csc.Sources = MSBuildUtil.CreateTaskItems("test1.cs", "test2.cs"); Assert.Equal("/out:test1.exe test1.cs test2.cs", csc.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()); }