Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save kellypleahy/2892749 to your computer and use it in GitHub Desktop.

Select an option

Save kellypleahy/2892749 to your computer and use it in GitHub Desktop.
### this is preamble (framework code), the user wouldn't type this.
$bindings = @{
projects = @()
}
function project($projectFilename, $block) {
function output-type($type) {
#maybe validate or translate, etc...
$bindings.outputType = $type
}
function framework-version($version) {
$bindings.frameworkVersion = $version
}
function project-type($projectType) {
$mappedType = switch($projectType) {
mvc2 { 'F85E285D-A4E0-4152-9332-AB1D724D3325' }
asp.net { '349C5851-65DF-11DA-9384-00065B846F21' }
csharpwindows { 'FAE04EC0-301F-11D3-BF4B-00C04F79EFBC' }
default { $null }
}
if($mappedType -eq $null) {
write-host "Warning: project-type code '$projectType' is unknown."
return
}
$bindings.projectTypes += $mappedType
}
function references($block) {
function assembly($name, $framework = $null, $path = $null, [switch]$specific, [switch]$notSpecific, [switch]$copy, [switch]$nocopy) {
$bindings.items += @{
name = $name
framework = $framework
path = $path
specific = $specific -or !$notSpecific
copyLocal = $copy -or !$nocopy
}
}
$references = & { $bindings = @{ defaultPath = $null; items = @() }; & $block; $bindings }
$bindings.references += $references
}
$project = @{
projectTypes = @()
references = @()
}
$project = & { $bindings = $project; & $block; $bindings }
$project.projectFilename = $projectFilename
$bindings.projects += $project
}
### this is the part the user would type!!!
project src/WebRole/WebRole.csproj {
output-type library
framework-version 4
project-type mvc2
project-type asp.net
project-type csharpwindows
references {
assembly System
assembly System.Core -framework 3.5
assembly Castle.Core -path packages\Castle.Core.2.5.2\lib\NET35\Castle.Core.dll
assembly 'Milliman.MGAlfa.Atb2, Version=7.4.118.0, Culture=neutral, processorArchitecture=MSIL' -notSpecific
assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL' -copy
}
}
### this is what we do afterwards.
# TODO: Actually create the project files
$bindings | Format-Table
@Ang3lFir3
Copy link
Copy Markdown

The example is plesant to read .... That's nice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment