-
Notifications
You must be signed in to change notification settings - Fork 71
The CSC task allows you to run the C# Compiler (csc.exe) directly, to compile your code and build your projects.
You can specify an array of files to build – your .cs files – what level of debug information to produce, define compiler constants, and more:
csc :build do |csc|
csc.compile "file1", "file2", ... "fileN"
csc.ouput = "myproject.dll"
csc.target :library
csc.debug = true # true, false, :full, :pdbonly
csc.define :whatever, :something, :etc
csc.doc = "path/to/docfile.xml"
csc.optimize = true # true or false
end
The resources can also be specified with Rake’s built in FileList, making it easy to use patterns to include or exclude specific files.
csc :build_app do |csc|
# exclude the test folder, which contains unit test code
csc.resources FileList["**/*.cs"].exclude "test/"
csc.output = "myproject.dll"
# other options, here
end
csc :build_tests do |csc|
csc.resources FileList["test/**/*.cs"]
# reference the project we already built, so our tests will find the classes they are testing
csc.references "myproject.dll"
# other options here
end
The CSC task provides a .use
method that tells the task which version of the .NET framework to use, to find the “csc.exe” tool. This method sets the .command
attribute for you, and can be called from the Albacore.configure
section, to set the .NET version to use, for all instances of the CSC task.
The default version is .NET 4.0. You only need to specify the version to use, if you need something other than this.
Albacore.configure do |config|
config.csc.use :net35
end
csc :build do |csc|
# override the pre-configured value for this specific task instance
csc.use :net20
end
Valid values for the .NET version to use, are:
- :net2
- :net20
- :net35
- :net4
- :net40
The following parameters are available for the CSC task.
Set the location of the “csc.exe” tool.
An array of files to compile.
An array of .NET assemblies to reference
An array of resources to embed into the output.
The file to output, including exection: .exe, .dll, etc. For example “myproject.dll” or “myproject.exe”
The type of output to create, specified as a symbol. See the MSDN documentation for a complete list.
Set the level of debug output.
- true
- false
- :full
- :pdbonly
Define compiler constants.
Produce xml documentation at this location.
Turn on, or off, compiler optimizations: true or false