コード例 #1
0
        public void RunStarted(object automationObject, Dictionary <string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
        {
            var doc = Helpers.LoadWizardXml(replacementsDictionary);
            var ns  = Helpers.WizardNamespace;

            var replacementGroups = ReplacementGroup.LoadXml(doc.Root.Elements(ns + "Replacements").FirstOrDefault());

            replacementGroups.SetMatchedItems(replacementsDictionary);

            var references = new List <ProjectReference>();

            foreach (var element in doc.Root.Elements(ns + "ProjectReferences").Elements(ns + "ProjectReference"))
            {
                references.Add(new ProjectReference(element, replacementsDictionary));
            }
            const string ProjectImportsKey    = "$ProjectImports$";
            const string ProjectReferencesKey = "$ProjectReferences$";

            if (!replacementsDictionary.ContainsKey(ProjectImportsKey))
            {
                replacementsDictionary[ProjectImportsKey] = string.Empty;
            }
            if (!replacementsDictionary.ContainsKey(ProjectReferencesKey))
            {
                replacementsDictionary[ProjectReferencesKey] = string.Empty;
            }

            if (references.Count > 0)
            {
                var isSharedLib = replacementsDictionary.GetParameter("UseSAL").ToBool();

                var projectReferences = new StringBuilder();

                if (isSharedLib)
                {
                    const string def = @"
  <Import Project=""{0}.projitems"" Label=""Shared"" Condition=""Exists('{0}.projitems')"" />";
                    foreach (var reference in references)
                    {
                        projectReferences.AppendFormat(def, reference.Reference, reference.Guid, reference.Name, reference.Extension);
                    }
                    replacementsDictionary[ProjectImportsKey] += projectReferences.ToString();
                }
                else
                {
                    const string def = @"
    <ProjectReference Include=""{0}.{3}"">
        <Project>{{{1}}}</Project>
        <Name>{2}</Name>
    </ProjectReference>";
                    foreach (var reference in references)
                    {
                        projectReferences.AppendFormat(def, reference.Reference, reference.Guid, reference.Name, reference.Extension);
                    }
                    replacementsDictionary[ProjectReferencesKey] += string.Format(@"
  <ItemGroup>{0}
  </ItemGroup>", projectReferences);
                }
            }
        }
コード例 #2
0
 public ProjectDefinition(XElement element, Dictionary <string, string> replacementsDictionary)
 {
     Name         = Helpers.ReplaceProperties((string)element.Attribute("name"), replacementsDictionary);
     Startup      = string.Equals((string)element.Attribute("startup"), "true", StringComparison.InvariantCultureIgnoreCase);
     Condition    = (string)element.Attribute("condition");
     Path         = Helpers.ReplaceProperties((string)element.Attribute("path") ?? element.Value, replacementsDictionary);
     Replacements = ReplacementGroup.LoadXml(element).ToList();
 }
コード例 #3
0
        public ReplacementGroup CreateReplacementAction()
        {
            ReplacementGroup group = new ReplacementGroup();

            foreach (var item in Replacements)
            {
                group.Append(Replacement.Create(item.Key, item.Value));
            }
            return(group);
        }
コード例 #4
0
        protected ReplacementGroup GetStandardProjectReplacement(ProjectSubstitutions config)
        {
            ReplacementGroup group = ReplacementGroup.Create(
                Replacement.Create("%CODE%", config.CSProjConfig),
                Replacement.Create("%REFERENCES%", config.References),
                Replacement.Create("%REFERENCES_BEFORE_PLATFORM%", config.ReferencesBeforePlatform),
                Replacement.Create("%NAME%", config.AssemblyNameOverride ?? Path.GetFileNameWithoutExtension(TemplateInfo.ProjectName)),
                Replacement.Create("%ITEMGROUP%", config.ItemGroup),
                Replacement.Create("%TARGET_FRAMEWORK_VERSION%", config.TargetFrameworkVersion));

            if (config.CustomProjectReplacement != null)
            {
                group.Append(Replacement.Create(config.CustomProjectReplacement.Item1, config.CustomProjectReplacement.Item2));
            }
            return(group);
        }