Example #1
0
        public BuildScript(string filename)
        {
            _sheet = new PropertySheet(_project);
            _sheet.ParseFile(filename);

            foreach(var target in _sheet.CurrentView.ReplaceableChildren ) {
                target.MapTo(_project.LookupTarget(target),PtkRoutes);
            }

            _sheet.Route(_project.ProjectRoutes());

            // convert #product-info into a dictionary.
            productInformation = _sheet.Metadata.Value.Keys.Where(each => each.StartsWith("product-info")).ToXDictionary(each => each.Substring(12), each => _sheet.Metadata.Value[each]);

            _sheet.CopyToModel();
        }
Example #2
0
        public PackageScript(string filename)
        {
            _nuspec.metadata.id = "Package";
            _nuspec.metadata.version = "1.0.0";
            _nuspec.metadata.authors = "NAME";
            _nuspec.metadata.owners = "NAME";
            _nuspec.metadata.licenseUrl = "http://LICENSE_URL_HERE_OR_DELETE_THIS_LINE";
            _nuspec.metadata.projectUrl = "http://PROJECT_URL_HERE_OR_DELETE_THIS_LINE";
            _nuspec.metadata.iconUrl = "http://ICON_URL_HERE_OR_DELETE_THIS_LINE";
            _nuspec.metadata.requireLicenseAcceptance = "false";
            _nuspec.metadata.description = "Package description";
            _nuspec.metadata.releaseNotes = "Summary of changes made in this release of the package.";
            _nuspec.metadata.copyright = "Copyright 2013";

            _sheet = new PropertySheet(this);

            // get the full path to the .autopkgFile
            var fullPath = filename.GetFullPath();
            autopkgFolder = Directory.GetParent(fullPath).FullName;

            // parse the script
            _sheet.ParseFile(filename);
            _sheet.ImportText(RequiredTemplate, "required");

            // ensure we have at least the package ID
            pkgName = _sheet.View.nuget.nuspec.id;
            if (string.IsNullOrEmpty(pkgName)) {
                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", pkgName);

            // generate the relative output paths.
            nuspecPath = Path.Combine(autopkgFolder, "{0}.nuspec".format(pkgName));
            propsPath = Path.Combine(autopkgFolder, "{0}.props".format(pkgName));
            targetsPath = Path.Combine(autopkgFolder, "{0}.targets".format(pkgName));

            // do the property sheet mapping
            var conditions = new XDictionary<string, string>();

            _sheet.Route("nuget.nuspec".MapTo(new object() , MapNuspec().ToArray() ));
            _sheet.Route("nuget.files".MapTo( new object() ,
                "condition".MapTo(conditions, key => Configurations.NormalizeConditionKey(key, _sheet.View.configurations as View)),
                "*".MapTo(conditions, key => Configurations.NormalizeConditionKey(key, _sheet.View.configurations as View))
                ));

            var hasProps = (_sheet.View.nuget.HasChild("props") && _sheet.View.nuget.props.HasChildren );
            var hasTargets = (_sheet.View.nuget.HasChild("targets") && _sheet.View.nuget.targets.HasChildren);

            if (hasProps) {
                _sheet.MapProject("nuget.props", _props);
                _sheet.MapConfigurations("configurations", _props);
            }

            if (hasTargets) {
                _sheet.MapProject("nuget.targets", _targets);
                _sheet.MapConfigurations("configurations", _targets);
            }

            // persist the propertysheet to the msbuild model.
            _sheet.View.CopyToModel();

            // generate automatic rules for lib/bin/include
            var implictRules = _sheet.CurrentView.GetMetadataValue("options.implicit-rules").IsNegative();

            // process files
            ProcessFiles(_sheet.View.nuget.files, autopkgFolder, implictRules, null);
        }