Created
May 18, 2017 07:17
-
-
Save devlead/0c082fe58cef72392d6bf8f60a4339e8 to your computer and use it in GitHub Desktop.
Example utilize csc.exe from cake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DirectoryPath projectPath = MakeAbsolute(Directory("./cscTest")); | |
DirectoryPath outputPath = projectPath.Combine("bin/Debug"); | |
FilePath asssemblyPath = outputPath.CombineWithFilePath("Test.dll"), | |
symbolsPath = outputPath.CombineWithFilePath("Test.pdb"); | |
FilePath[] references = new FilePath[0]; // add any assembly dependencies | |
Task("Clean") | |
.Does(() => { | |
CleanDirectory(outputPath); | |
}); | |
Task("Build") | |
.IsDependentOn("Clean") | |
.Does(() => { | |
var arguments = new ProcessArgumentBuilder() | |
.Append("/debug") | |
.AppendSwitch("/target", ":", "library") // exe, winexe... | |
.AppendSwitchQuoted("/out",":", asssemblyPath.FullPath) | |
.AppendSwitchQuoted("/pdb",":", symbolsPath.FullPath) | |
.Append("/recurse:*.cs"); | |
Array.ForEach( | |
references, | |
refeence => arguments.AppendSwitchQuoted("/reference", ":", refeence.FullPath) | |
); | |
var result = StartProcess( | |
"csc.exe", // needs to be full path if not in path | |
new ProcessSettings { | |
WorkingDirectory = projectPath, | |
Arguments = arguments | |
} | |
); | |
if (result != 0) | |
{ | |
throw new Exception(string.Format("csc.exe exited with {0}", result)); | |
} | |
}); | |
RunTarget("Build"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment