coapp/coapp.powershell — pull request #96 by gordonwatts (2014-11-06 01:38:44+00:00)
Title: Custom tasks

This patch is the first step to declaring a custom MSBuild task for use in an autopkg file (see issue #95).

Under the nuget node one can write:

customtasks {
task {
name = AddDebugEnv;
DLL = ..\ROOTPackageBuilders\ROOTMSBuildTasks\bin\Release\ROOTMSBuildTasks.dll;
};
};

And then one can write:

targets {
AfterBuild {
.AddDebugEnv {
EnvVarName = "PYTHIA8Data";
EnvValue = "$(SolutionDir)\$(Configuration)\Pythia8Data" ;
UserSettingsPath = "$(ProjectPath).user";
ConfigPlatform = "$(Configuration)|$(Platform)";
};
}
}

While the code works and will produce a working nupkg file with overlays that runs the custom task, there are two known issues with this pull request:

1. The mapping from the property sheets and views into the MSBuild object model is difficult for me to figure out. See line 190 in the patch for PackageScript.cs below. It is wrong, but it "works". If someone can give me some guidance on how that should work, I'll update this.

2. The AddDebugEnv currently generates a warning ("Unknown task"). Given the DLL is known, there is no reason Write-Nuget can't load it and its tasks the way it does for the regular msbuild tasks (see MsBuildMap.cs). Unfortunately, the "targets" view in the input source file gets parsed before the "customtasks" node. Seemingly no matter how I re-order the MapTo's in the PackageScript.cs file or in my input file. If someone can give me a hint there, I'll make the rest of the changes to get it scanning the new DLL files.

Any help addressing those issues would be gratefully accepted! Or, obviously, a change in my approach to implementing this as long as there is some way to accomplish what I'm trying to do here!