Skip to content

Instantly share code, notes, and snippets.

@devlead
Created May 18, 2017 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devlead/0c082fe58cef72392d6bf8f60a4339e8 to your computer and use it in GitHub Desktop.
Save devlead/0c082fe58cef72392d6bf8f60a4339e8 to your computer and use it in GitHub Desktop.
Example utilize csc.exe from cake
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