示例#1
0
 private static IEnumerable <string> GetResultLabels(VSProjectUpdateResult result)
 {
     if (result.SourceRemovedCount != 0)
     {
         yield return($"{result.SourceRemovedCount} source removed");
     }
     if (result.SourceAddedCount != 0)
     {
         yield return($"{result.SourceAddedCount} source added");
     }
     if (result.SourceLinkRemovedCount != 0)
     {
         yield return($"{result.SourceLinkRemovedCount} source link removed");
     }
     if (result.SourceLinkAddedCount != 0)
     {
         yield return($"{result.SourceLinkAddedCount} source link added");
     }
     if (result.AssemblyReferenceRemovedCount != 0)
     {
         yield return($"{result.AssemblyReferenceRemovedCount} assembly reference removed");
     }
     if (result.AssemblyReferenceAddedCount != 0)
     {
         yield return($"{result.AssemblyReferenceAddedCount} assembly reference added");
     }
 }
示例#2
0
        private static string GetResultLabel(VSProjectUpdateResult result)
        {
            // 0 source removed, 0 source added, 0 source link removed, 0 source link added, 0 assembly reference removed, 0 assembly reference added
            string label = GetResultLabels(result).zConcatStrings(", ");

            if (label == null)
            {
                label = "nothing done";
            }
            return(label);
        }
示例#3
0
        public void UpdateVSProject(string runsourceProject, VSProjectUpdateOptions options)
        {
            //RunSourceVSProjectManager manager = new RunSourceVSProjectManager();
            if (!Init(runsourceProject, options))
            {
                return;
            }
            TraceHeader();
            VSProjectUpdateResult result = _UpdateVSProject();

            TraceResult(result);
        }
示例#4
0
        private VSProjectUpdateResult _UpdateVSProject()
        {
            VSProjectUpdateResult result = new VSProjectUpdateResult();

            if ((_options & VSProjectUpdateOptions.RemoveSource) == VSProjectUpdateOptions.RemoveSource)
            {
                result.SourceRemovedCount = RemoveSources();
            }

            if ((_options & VSProjectUpdateOptions.AddSource) == VSProjectUpdateOptions.AddSource)
            {
                result.SourceAddedCount = AddSources();
            }

            if ((_options & VSProjectUpdateOptions.RemoveSourceLink) == VSProjectUpdateOptions.RemoveSourceLink)
            {
                result.SourceLinkRemovedCount = RemoveSourcesLinks();
            }

            if ((_options & VSProjectUpdateOptions.AddSourceLink) == VSProjectUpdateOptions.AddSourceLink)
            {
                result.SourceLinkAddedCount = AddSourcesLinks();
            }

            if ((_options & VSProjectUpdateOptions.RemoveAssemblyReference) == VSProjectUpdateOptions.RemoveAssemblyReference)
            {
                result.AssemblyReferenceRemovedCount = RemoveAssembliesReferences();
            }

            if ((_options & VSProjectUpdateOptions.AddAssemblyReference) == VSProjectUpdateOptions.AddAssemblyReference)
            {
                result.AssemblyReferenceAddedCount = AddAssembliesReferences();
            }

            if (_vsProjectManager.ProjectModified && (_options & VSProjectUpdateOptions.Simulate) != VSProjectUpdateOptions.Simulate)
            {
                if ((_options & VSProjectUpdateOptions.BackupVSProject) == VSProjectUpdateOptions.BackupVSProject)
                {
                    //Trace.WriteLine($"  backup \"{_vsProjectManager.ProjectFile}\"");
                    BackupVSProject(_vsProjectManager.ProjectFile, _backupVSProjectDirectory);
                }
                //Trace.WriteLine($"  save \"{_vsProjectManager.ProjectFile}\"");
                _vsProjectManager.Save();
            }

            //result.Success = true;
            return(result);
        }
示例#5
0
 private static void TraceResult(VSProjectUpdateResult result)
 {
     Trace.WriteLine($"  {GetResultLabel(result)}");
 }