コード例 #1
0
        static void Main(string[] args)
        {
            try
            {
                var cpPath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

                //find the root path of the SamplePackager
                var parent = new DirectoryInfo(cpPath).Parent.Parent.Parent.Parent.Parent;

                //var solutionPath = Path.Combine(parent.FullName, @"TestSolution\SampleApplication\SampleApplication.sln");
                //var solutionPath = Path.Combine(parent.FullName, @"TestSolution2\Samples\SampleApplication.sln");

                var solutionPath = @"C:\Users\dave\Desktop\ARCore\samples\HelloAR.sln";

                var outPutPath = @"C:\SamplePackagerOutput\ARCoreSamples";

                //var packageVersions = new Dictionary<string, string>()
                //{
                //    {"StandardSample","1.1.0" },
                //    {"AndroidLibary","1.1.0" },
                //};

                var outputfile = SolutionProcessor.Process(solutionPath, outPutPath);

                Console.WriteLine("Complete");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadLine();
        }
コード例 #2
0
        public void ProcessShouldProduceListOfSolutionFilesWithoutExcludes()
        {
            var testData = new List <(string path, SolutionDescription desc)>
            {
                (Path.Combine(BasePath, @"projects-finder\SonarSolutionsAnalyzer.Tests\test.sln"),
                 new SolutionDescription {
                    Name = "test"
                }),
                (Path.Combine(BasePath, @"projects-finder\SonarSolutionsAnalyzer.Tests\test-wt.sln"),
                 new SolutionDescription {
                    Name = "test-wt"
                })
            };
            var solutionBuilderMock = new Mock <ISolutionDescriptorBuilder>();

            foreach (var(path, desc) in testData)
            {
                solutionBuilderMock.Setup(x => x.Build(path)).Returns(desc).Verifiable();
            }

            var target = new SolutionProcessor(new Configuration {
                RootPath = BasePath
            }, solutionBuilderMock.Object, () => testData.Select(x => x.path));
            var result = target.Process();

            Assert.Collection(
                result,
                d => Assert.Equal(d.Name, testData[0].desc.Name),
                d => Assert.Equal(d.Name, testData[1].desc.Name)
                );
            solutionBuilderMock.Verify();
        }
コード例 #3
0
        public void ProcessShouldProduceListOfSolutionFilesWithIncludes()
        {
            var testData = new List <(string path, SolutionDescription desc)>
            {
                (Path.Combine(BasePath, @"projects-finder\SonarSolutionsAnalyzer.Tests\test.sln"),
                 new SolutionDescription {
                    Name = "test"
                }),
                (Path.Combine(BasePath, @"exclude1\exlude2\SonarSolutionsAnalyzer.Tests\test-wt.sln"),
                 new SolutionDescription {
                    Name = "test-wt"
                }),
                (Path.Combine(BasePath, @"exclude\SonarSolutionsAnalyzer.Tests\test1.sln"),
                 new SolutionDescription {
                    Name = "test1"
                }),
                (Path.Combine(BasePath, @"include2\test2.sln"),
                 new SolutionDescription {
                    Name = "test2"
                })
            };
            var solutionBuilderMock = new Mock <ISolutionDescriptorBuilder>();

            foreach (var(path, desc) in testData)
            {
                solutionBuilderMock.Setup(x => x.Build(path)).Returns(desc);
            }

            var target = new SolutionProcessor(
                new Configuration
            {
                RootPath      = BasePath,
                IncludedPaths = new List <string>
                {
                    Path.Combine(BasePath, @"projects-finder"),
                    @"include2"
                }
            },
                solutionBuilderMock.Object,
                () => testData.Select(x => x.path)
                );

            var result = target.Process().ToList();

            solutionBuilderMock.Verify(x => x.Build(testData[0].path), Times.Once);
            solutionBuilderMock.Verify(x => x.Build(testData[1].path), Times.Never);
            solutionBuilderMock.Verify(x => x.Build(testData[2].path), Times.Never);
            solutionBuilderMock.Verify(x => x.Build(testData[3].path), Times.Once);
            Assert.Collection(
                result,
                d => Assert.Equal(d.Name, testData[0].desc.Name),
                d => Assert.Equal(d.Name, testData[3].desc.Name)
                );
        }
コード例 #4
0
        protected override void Run()
        {
            var item = IdeApp.ProjectOperations.CurrentSelectedItem;

            var sln = item as Solution;

            if (sln != null)
            {
                SolutionProcessor.NukeBinObj(sln);
                return;
            }

            var prj = item as Project;

            if (prj != null)
            {
                SolutionProcessor.NukeBinObj(prj);
            }
        }
コード例 #5
0
        public void LoadProjects()
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            using (var solutionProcessor = new SolutionProcessor(mCurrentSolution))
            {
                var projVers = solutionProcessor.BuildVersions(mCurrentSolution);


                ShowUnloadedWarning = solutionProcessor.DetectedUnloadedProjects;
                FailedProjects      = solutionProcessor.FailedProjects;

                foreach (var item in projVers.OrderBy(projver => projver.Name))
                {
                    this.Items.Add(item);
                }


                ShowIos     = projVers.HasIosMac;
                ShowAndroid = projVers.HasAndroid;

                Version outVersion = null;

                if (System.Version.TryParse(AssemblyVersion, out outVersion))
                {
                    if (ShowIos)
                    {
                        CocoaShortVersion = CocoaAppVersion.ToShortVersion(outVersion);
                    }

                    if (ShowAndroid)
                    {
                        AndroidBuild = AndroidAppVersion.ToBuild(outVersion);
                    }
                }
            }


            LoadAssVersion();

            LoadAssFileVersion();
        }
コード例 #6
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object senderObj, EventArgs args)
        {
            if (senderObj is OleMenuCommand && args is OleMenuCmdEventArgs)
            {
                var solutionProcessor = new SolutionProcessor(_ide);
                var projects          = solutionProcessor.GetAllSolutionProjects();

                var messageBoxService = new MessageBoxService();
                var migrationService  = new MigrationService(messageBoxService);

                var viewModel = new AddMigrationViewModel(projects, solutionProcessor, migrationService, messageBoxService);
                var window    = new AddMigration(viewModel);

                messageBoxService.ShowInfoMessageFunc =
                    msg => showMessageBox(window, msg, MessageBoxImage.Information);
                messageBoxService.ShowErrorMessageFunc =
                    msg => showMessageBox(window, msg, MessageBoxImage.Error);
                messageBoxService.ShowWarningMessageFunc =
                    msg => showMessageBox(window, msg, MessageBoxImage.Warning);

                window.ShowModal();
            }
        }
コード例 #7
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void MenuItemCallback(object senderObj, EventArgs args)
        {
            if (senderObj is OleMenuCommand && args is OleMenuCmdEventArgs)
            {
                var solutionProcessor = new SolutionProcessor(_ide);
                var projects          = solutionProcessor.GetAllSolutionProjects();

                var messageBoxService = new MessageBoxService();
                var dbService         = new MsSqlServerService();
                var scaffoldingVM     = new ScaffoldingWizardViewModel(
                    messageBoxService, dbService, dbService, new ScaffoldingService(), projects);
                var scaffoldingWindow = new ScaffoldingWizard(scaffoldingVM);

                messageBoxService.ShowInfoMessageFunc =
                    msg => showMessageBox(scaffoldingWindow, msg, MessageBoxImage.Information);
                messageBoxService.ShowErrorMessageFunc =
                    msg => showMessageBox(scaffoldingWindow, msg, MessageBoxImage.Error);
                messageBoxService.ShowWarningMessageFunc =
                    msg => showMessageBox(scaffoldingWindow, msg, MessageBoxImage.Warning);

                scaffoldingWindow.ShowModal();
            }
        }
コード例 #8
0
        public void ProcessUpdates()
        {
            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();

                Version newVersion;
                Version fileVersion = null;

                //add support for dynamic build revision values
                var theVersion = (forceSemVer) ? $"{AssemblyMajor ?? "0"}.{AssemblyMinor ?? "0"}.{AssemblyBuild ?? "0"}" : this.AssemblyVersion;

                newVersion = new Version(theVersion);

                var newVersionValue = (newVersion.Revision == -1) ? $"{newVersion.Major}.{newVersion.Minor}.{newVersion.Build}.0" : newVersion.ToString();

                if (mSeparateVersions)
                {
                    var vers = (forceSemVer) ? $"{AssemblyFileMajor ?? "0"}.{AssemblyFileMinor ?? "0"}.{AssemblyFileBuild ?? "0"}" : this.FileVersion;

                    fileVersion = new Version(vers);
                }


                var _serviceProvider = new ServiceProvider(mApplication as Microsoft.VisualStudio.OLE.Interop.IServiceProvider);
                var _sln             = (IVsSolution)_serviceProvider.GetService(typeof(SVsSolution));

                if (_sln == null)
                {
                    throw new Exception("Unable to find the solution");
                }

                using (var solutionProcessor = new SolutionProcessor(mCurrentSolution))
                {
                    foreach (ProjectVersion ver in Items)
                    {
                        if (ver.Update)
                        {
                            if (ver.IsNewStyleProject == true)
                            {
                                solutionProcessor.UpdateProject(ver.RealProject, newVersion, fileVersion);
                            }
                            else
                            {
                                solutionProcessor.UpdateFile(ver.ProjectItem, newVersion, fileVersion);
                            }


                            if (UpdateClickOnce)
                            {
                                IVsHierarchy hiearachy = null;
                                _sln.GetProjectOfUniqueName(ver.RealProject.FullName, out hiearachy);

                                Guid aGuid;

                                _sln.GetGuidOfProject(hiearachy, out aGuid);

                                IVsBuildPropertyStorage buildPropStorage = (IVsBuildPropertyStorage)hiearachy;

                                string propValue;
                                buildPropStorage.GetPropertyValue("ApplicationVersion", "Debug", (uint)_PersistStorageType.PST_PROJECT_FILE, out propValue);

                                if (!String.IsNullOrWhiteSpace(propValue))
                                {
                                    var xmldoc = XDocument.Load(ver.RealProject.FullName);

                                    XNamespace msbuild = "http://schemas.microsoft.com/developer/msbuild/2003";

                                    bool hasChanged = false;
                                    foreach (var resource in xmldoc.Descendants(msbuild + "ApplicationVersion"))
                                    {
                                        string curVersion = resource.Value;

                                        if (!curVersion.Equals(this.AssemblyVersion))
                                        {
                                            resource.Value = newVersionValue;

                                            hasChanged = true;
                                        }
                                    }

                                    if (hasChanged)
                                    {
                                        var stP = mApplication.Solution.Properties.Item("StartupProject").Value;

                                        var stPName = ver.RealProject.Name;

                                        var aFileName = ver.RealProject.FullName;

                                        var _sln2 = (IVsSolution4)_serviceProvider.GetService(typeof(SVsSolution));

                                        if (_sln2 == null)
                                        {
                                            throw new Exception("Unable to access the solution");
                                        }

                                        _sln2.UnloadProject(aGuid, (uint)_VSProjectUnloadStatus.UNLOADSTATUS_UnloadedByUser);

                                        xmldoc.Save(aFileName);

                                        IVsHierarchy hiearachy2 = null;
                                        _sln.GetProjectOfUniqueName(aFileName, out hiearachy2);

                                        Guid aGuid2;

                                        _sln.GetGuidOfProject(hiearachy2, out aGuid2);

                                        if (aGuid != aGuid2)
                                        {
                                            Console.WriteLine("");
                                        }

                                        _sln2.ReloadProject(aGuid);

                                        if (stP.Equals(stPName))
                                        {
                                            mApplication.Solution.Properties.Item("StartupProject").Value = stPName;
                                        }
                                    }
                                }
                            }

                            if (ver.SecondaryProjectItem != null)
                            {
                                if (ver.IsCocoa == true)
                                {
                                    var secFile = ver.SecondaryProjectItem.FileNames[0];

                                    var aUpdater = new CocoaAppVersion()
                                    {
                                        FilePath = secFile
                                    };

                                    aUpdater.VersionOne = cocoaShortVersion;
                                    aUpdater.VersionTwo = newVersionValue;
                                    aUpdater.Update();
                                }
                                else if (ver.IsAndroid == true)
                                {
                                    var secFile = ver.SecondaryProjectItem.FileNames[0];

                                    var aUpdater = new AndroidAppVersion()
                                    {
                                        FilePath = secFile
                                    };

                                    aUpdater.VersionOne = androidBuild;
                                    aUpdater.VersionTwo = newVersionValue;
                                    aUpdater.Update();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
                //throw new Exception("One of the versions specified is not valid");
            }
        }
コード例 #9
0
        public void LoadProjects()
        {
            try
            {
                ThreadHelper.ThrowIfNotOnUIThread();



                using (var solutionProcessor = new SolutionProcessor(mCurrentSolution))
                {
                    solutionProcessor.OnLoadedProjects += (s, e) =>
                    {
                        TotalProjects = e;

                        LoadingProgressUpdated(this, null);
                    };

                    solutionProcessor.OnStartingProject += (s, e) =>
                    {
                        CurrentProject     = e.Item1;
                        CurrentProjectName = e.Item2;

                        LoadingProgressUpdated(this, null);
                    };

                    var projVers = solutionProcessor.BuildVersions(mCurrentSolution);
                    ShowUnloadedWarning = solutionProcessor.DetectedUnloadedProjects;
                    FailedProjects      = solutionProcessor.FailedProjects;

                    foreach (var item in projVers.OrderBy(projver => projver.Name))
                    {
                        this.Items.Add(item);
                    }


                    ShowIos     = projVers.HasIosMac;
                    ShowAndroid = projVers.HasAndroid;

                    Version outVersion = null;

                    if (System.Version.TryParse(AssemblyVersion, out outVersion))
                    {
                        if (ShowIos)
                        {
                            CocoaShortVersion = CocoaAppVersion.ToShortVersion(outVersion);
                        }

                        if (ShowAndroid)
                        {
                            AndroidBuild = AndroidAppVersion.ToBuild(outVersion);
                        }
                    }
                }


                LoadAssVersion();

                LoadAssFileVersion();

                IsLoaded = true;

                IsBusy = false;
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.Message, "Error loading projects");
            }
        }
コード例 #10
0
        public static string OnGeneratedSlnSolution(string _, string content)
        {
            var options = NugetOptionsFactory.CreateDefault().LoadFromFile();

            return(SolutionProcessor.CreateDefault(options).ProcessSolutionFile(content));
        }