public PackageScript(string filename)
{
Event<Verbose>.Raise("PackageScript", "Constructor");
_sheet = new RootPropertySheet(this);
// get the full path to the .autopkgFile
FullPath = filename.GetFullPath();
// parse the script
_sheet.ParseFile(filename);
_sheet.ImportText(_requiredTemplate, "required");
// temp hack to work around static & ltcg getting marked as used when they are just in the template.
var scriptText = File.ReadAllText(filename);
if (scriptText.IndexOf("static", StringComparison.InvariantCultureIgnoreCase) > -1) {
_sheet.ImportText(_requiredTemplateStatic, "required_static");
}
// end hack
if (scriptText.IndexOf("ltcg", StringComparison.InvariantCultureIgnoreCase) > -1) {
_sheet.ImportText(_requiredTemplateLTCG, "required_ltcg");
}
// ensure we have at least the package ID
var packageName = _sheet.View.nuget.nuspec.id;
if (string.IsNullOrEmpty(packageName)) {
throw new ClrPlusException("the Field nuget.nuspec.id can not be null or empty. You must specify an id for a package.");
}
// set the package name macro
_sheet.AddMacro("pkgname", packageName);
_sheet.CurrentView.AddMacroHandler( (name, context) => _macros.ContainsKey(name.ToLower()) ? _macros[name.ToLower()] : null);
_sheet.CurrentView.AddMacroHandler((name, context) => System.Environment.GetEnvironmentVariable(name));
Pivots = new Pivots(_sheet.CurrentView.GetProperty("configurations"));
}