private void InitializeNuget() { View nugetView = _sheet.View.nuget; _nuget = nugetView; if (!nugetView.HasChildren) { FailAlways(Event <SourceError> .Raise("AP100", _sheet.CurrentView.SourceLocations, "script does not contain a declaration for a NuGet package")); } _nuspec = _nuget.nuspec; if (!_nuspec.HasChildren) { FailAlways(Event <SourceError> .Raise("AP102", nugetView.SourceLocations, "script does not contain a 'nuspec' declaration in 'nuget'")); } if (string.IsNullOrEmpty(_nuspec.id.Value)) { FailAlways(Event <SourceError> .Raise("AP103", _nuspec.SourceLocations, "script does not contain a 'id' declaration in 'nuspec'")); } NugetPackage = new NugetPackage(this, PackageRole.@default, _nuspec.id.Value); nugetView.AddChildRoutes(NugetPackage.Initialize()); // do the property sheet mapping var conditions = new XDictionary <string, string>(); // map the file routes nugetView.AddChildRoute("files".MapTo(new object(), new [] { "condition".MapTo(conditions, key => Pivots.GetExpressionFilepath(_nuspec.id, nugetView.ResolveMacrosInContext(key))), "*".MapTo(conditions, key => Pivots.GetExpressionFilepath(_nuspec.id, nugetView.ResolveMacrosInContext(key))) })); var nuspecid = _nuspec.id; var conditionFolderMacroHander = (GetMacroValueDelegate)((macro, context) => { if (macro == "conditionFolder") { return(LinqExtensions.SingleItemAsEnumerable(Pivots.GetExpressionFilepath(nuspecid, ((View)context).GetSingleMacroValue("ElementId") ?? ""))); } return(null); }); _nuget.props.AddMacroHandler(conditionFolderMacroHander); _nuget.targets.AddMacroHandler(conditionFolderMacroHander); nugetView.AddChildRoute("props".MapTo(NugetPackage.Props.Value /*, GetPropsProject("default").ProjectRoutes() */)); // always need a targets nugetView.AddChildRoute("targets".MapTo(NugetPackage.Targets.Value /*, GetTargetsProject("default").ProjectRoutes() */)); // other variants/frameworks }
private void InitializeNuget() { View nugetView = _sheet.View.nuget; _nuget = nugetView; if (!nugetView.HasChildren ) { FailAlways(Event<SourceError>.Raise("AP100", _sheet.CurrentView.SourceLocations, "script does not contain a declaration for a NuGet package")); } _nuspec = _nuget.nuspec; if(!_nuspec.HasChildren) { FailAlways(Event<SourceError>.Raise("AP102", nugetView.SourceLocations, "script does not contain a 'nuspec' declaration in 'nuget'")); } if(string.IsNullOrEmpty(_nuspec.id.Value)) { FailAlways(Event<SourceError>.Raise("AP103", _nuspec.SourceLocations, "script does not contain a 'id' declaration in 'nuspec'")); } NugetPackage = new NugetPackage(this, PackageRole.@default, _nuspec.id.Value); nugetView.AddChildRoutes(NugetPackage.Initialize()); // do the property sheet mapping var conditions = new XDictionary<string, string>(); // map the file routes nugetView.AddChildRoute("files".MapTo(new object() , new [] { "condition".MapTo(conditions, key => Pivots.GetExpressionFilepath(_nuspec.id, nugetView.ResolveMacrosInContext(key))), "*".MapTo(conditions, key => Pivots.GetExpressionFilepath(_nuspec.id, nugetView.ResolveMacrosInContext(key))) })); var nuspecid = _nuspec.id; var conditionFolderMacroHander = (GetMacroValueDelegate)((macro, context) => { if (macro == "conditionFolder") { return LinqExtensions.SingleItemAsEnumerable(Pivots.GetExpressionFilepath(nuspecid, ((View)context).GetSingleMacroValue("ElementId")??"")); } return null; }); _nuget.props.AddMacroHandler(conditionFolderMacroHander); _nuget.targets.AddMacroHandler(conditionFolderMacroHander); nugetView.AddChildRoute("props".MapTo(NugetPackage.Props.Value /*, GetPropsProject("default").ProjectRoutes() */)); // always need a targets nugetView.AddChildRoute("targets".MapTo(NugetPackage.Targets.Value/*, GetTargetsProject("default").ProjectRoutes() */)); // other variants/frameworks }