Esempio n. 1
0
        protected virtual void CreateNewSolutionPackage(MetaPackServiceContext service,
                                                        RegressinModelLevel modelLevel)
        {
            var solutionPackage = CreateNewSolutionPackage(service.PackagingService, null, modelLevel);

            UpdatePackageVersion(solutionPackage);
            PushPackageToCIRepository(solutionPackage, null, service.PackagingService);
        }
Esempio n. 2
0
        private void Internal_Can_Deploy_SolutionPackage_On_O365_Site_CSOM(MetaPackServiceContext s)
        {
            var regressionProfile = new RegressionDeploymentProfile();

            regressionProfile.Sandbox    = RegressionSandbox.O365;
            regressionProfile.API        = RegressionAPI.CSOM;
            regressionProfile.ModelLevel = RegressinModelLevel.Site;

            Internal_Deploy_SolutionPackage(s, regressionProfile);
        }
Esempio n. 3
0
        public void Internal_Can_Deploy_SolutionPackage_On_SharePoint_Farm_SSOM(MetaPackServiceContext s)
        {
            var regressionProfile = new RegressionDeploymentProfile();

            regressionProfile.Sandbox    = RegressionSandbox.SharePoint;
            regressionProfile.API        = RegressionAPI.SSOM;
            regressionProfile.ModelLevel = RegressinModelLevel.Farm;

            Internal_Deploy_SolutionPackage(s, regressionProfile);
        }
Esempio n. 4
0
        private void Internal_Can_Deploy_SolutionPackage_On_O365_Web_CSOM(MetaPackServiceContext s, bool isSubWeb)
        {
            var regressionProfile = new RegressionDeploymentProfile();

            regressionProfile.Sandbox    = RegressionSandbox.O365;
            regressionProfile.API        = RegressionAPI.CSOM;
            regressionProfile.ModelLevel = RegressinModelLevel.Web;

            if (isSubWeb)
            {
                regressionProfile.ModelLevel = RegressinModelLevel.Subweb;
            }

            Internal_Deploy_SolutionPackage(s, regressionProfile);
        }
Esempio n. 5
0
        public void Internal_Can_Deploy_SolutionPackage_On_SharePoint_Web_SSOM(MetaPackServiceContext s, bool isSubweb)
        {
            var regressionProfile = new RegressionDeploymentProfile();

            regressionProfile.Sandbox    = RegressionSandbox.SharePoint;
            regressionProfile.API        = RegressionAPI.SSOM;
            regressionProfile.ModelLevel = RegressinModelLevel.Web;

            if (isSubweb)
            {
                regressionProfile.ModelLevel = RegressinModelLevel.Subweb;
            }

            Internal_Deploy_SolutionPackage(s, regressionProfile);
        }
Esempio n. 6
0
        public MetaPackScenarioTestBase()
        {
            var useSPMeta2Provider       = true;
            var useSharePointPnPProvider = false;

            var files2delete = new List <string>();

            files2delete.AddRange(Directory.GetFiles(Directory.GetCurrentDirectory(), "SPMeta2.CSOM**dll"));
            files2delete.AddRange(Directory.GetFiles(Directory.GetCurrentDirectory(), "Microsoft.SharePoint.Client**dll"));

            foreach (var f in files2delete)
            {
                try
                {
                    System.IO.File.Delete(f);
                }
                catch (Exception e)
                {
                }
            }


            var regressionTraceService = new RegressionTraceService();

            SPMeta2SolutionPackagingService       = new SPMeta2SolutionPackageService();
            SharePointPnPSolutionPackagingService = new SharePointPnPSolutionPackageService();

            MetaPackServiceContainer.Instance.ReplaceService(typeof(TraceServiceBase), regressionTraceService);

            UseLocaNuGet = true;

            InitEnvironmentVariables();

            SPMeta2ServiceContext = new MetaPackServiceContext
            {
                PackagingService  = new SPMeta2SolutionPackageService(),
                DeploymentService = new SPMeta2SolutionPackageDeploymentService(),

                ToolPackage = new SolutionToolPackage
                {
                    Id = "MetaPack.SPMeta2"
                },

                CIPackageId = "MetaPack.SPMeta2.CI"
            };

            SharePointPnPServiceContext = new MetaPackServiceContext
            {
                PackagingService  = new SharePointPnPSolutionPackageService(),
                DeploymentService = new SharePointPnPSolutionDeploymentService(),

                ToolPackage = new SolutionToolPackage
                {
                    Id = "MetaPack.SharePointPnP"
                },

                CIPackageId = "MetaPack.SharePointPnP.CI"
            };

            //if (!Environment.Is64BitProcess)
            //    throw new Exception("x64 process is requred. VS -> Test -> Test Settings -> Default process architecture -> x64");

            // packaging
            MetaPackService = new List <MetaPackServiceContext>();

            if (useSPMeta2Provider)
            {
                MetaPackService.Add(SPMeta2ServiceContext);
            }

            if (useSharePointPnPProvider)
            {
                MetaPackService.Add(SharePointPnPServiceContext);
            }

            var localAssemblyDirectoryPath = Path.GetDirectoryName(GetType().Assembly.Location);
            var localNuGetFolder           = Path.GetFullPath(localAssemblyDirectoryPath + @"\..\..\..\Build\local-ci-packages");

            LocalNuGetRepositoryFolderPath = localNuGetFolder;

            Directory.CreateDirectory(LocalNuGetRepositoryFolderPath);

            if (UseLocaNuGet)
            {
                var toolResolutionService = new ToolResolutionService();
                toolResolutionService.PackageSources.Add(LocalNuGetRepositoryFolderPath);

                // environment varioable must go first so that we can override stuff
                toolResolutionService.InitPackageSourcesFromGetEnvironmentVariable("MetaPack.NuGet.Galleries", EnvironmentVariableTarget.Machine);
                toolResolutionService.InitPackageSourcesFromGetEnvironmentVariable("MetaPack.NuGet.Galleries", EnvironmentVariableTarget.User);
                toolResolutionService.InitPackageSourcesFromGetEnvironmentVariable("MetaPack.NuGet.Galleries", EnvironmentVariableTarget.Process);

                toolResolutionService.InitPackageSourcesFromString(ConfigurationManager.AppSettings["NuGet.Galleries"]);

                toolResolutionService.RefreshPackageManager();

                MetaPackServiceContainer.Instance.RegisterService(typeof(ToolResolutionService), toolResolutionService);
            }
        }
Esempio n. 7
0
 protected virtual void CreateNewSolutionPackage(MetaPackServiceContext service)
 {
     CreateNewSolutionPackage(service, RegressinModelLevel.Site);
 }
Esempio n. 8
0
        private void Internal_Deploy_SolutionPackage(
            MetaPackServiceContext regressionContext,
            RegressionDeploymentProfile regressionProfile)
        {
            var packagingService  = regressionContext.PackagingService;
            var deploymentService = regressionContext.DeploymentService;

            // create new solution package for this deployment
            var ciSolutionPackage = CreateNewSolutionPackage(packagingService, regressionProfile.ModelLevel);

            UpdatePackageVersion(ciSolutionPackage);

            var packageId      = ciSolutionPackage.Id;
            var packageVersion = ciSolutionPackage.Version;

            // push to repo
            PushPackageToCIRepository(ciSolutionPackage, null, packagingService);

            // find
            var ciPackage = FindPackageInCIRepository(packageId, packageVersion);

            Assert.IsNotNull(ciPackage, "Solution package");

            var solutionOptions = new List <OptionValue>();

            WithCIRepositoryContext(ciNuGetRepository =>
            {
                // actual deployment callback
                Action <ClientContext, IPackage, List <OptionValue> > metapackDeployment =
                    (clientContext, package, options) =>
                {
                    var packageManager = new DefaultMetaPackSolutionPackageManager(ciNuGetRepository, clientContext);

                    // configura options
                    packageManager.SolutionOptions.AddRange(options);

                    // install package
                    packageManager.InstallPackage(package, false, false);
                };

                if (regressionProfile.Sandbox == RegressionSandbox.O365)
                {
                    var siteUrl      = O365RootWebUrl;
                    var userName     = O365UserName;
                    var userPassword = O365UserPassword;

                    // checking correct model
                    if (regressionProfile.ModelLevel == RegressinModelLevel.Site)
                    {
                        siteUrl = O365RootWebUrl;
                    }
                    else if (regressionProfile.ModelLevel == RegressinModelLevel.Web)
                    {
                        siteUrl = O365RootWebUrl;
                    }
                    else if (regressionProfile.ModelLevel == RegressinModelLevel.Subweb)
                    {
                        siteUrl = O365SubWebUrl;
                    }
                    else
                    {
                        throw new NotImplementedException(
                            string.Format("Unsupported ModelLevel type:[{0}]",
                                          regressionProfile.ModelLevel));
                    }

                    // csom related options
                    solutionOptions.Add(DefaultOptions.SharePoint.Api.CSOM);
                    solutionOptions.Add(DefaultOptions.SharePoint.Edition.Standard);
                    solutionOptions.Add(DefaultOptions.SharePoint.Version.O365);

                    solutionOptions.Add(new OptionValue
                    {
                        Name  = DefaultOptions.Site.Url.Id,
                        Value = siteUrl
                    });

                    solutionOptions.Add(new OptionValue
                    {
                        Name  = DefaultOptions.User.Name.Id,
                        Value = userName
                    });

                    solutionOptions.Add(new OptionValue
                    {
                        Name  = DefaultOptions.User.Password.Id,
                        Value = userPassword
                    });

                    WithCIO365ClientContext(siteUrl, userName, userPassword, context =>
                    {
                        metapackDeployment(context, ciPackage, solutionOptions);
                    });
                }
                else if (regressionProfile.Sandbox == RegressionSandbox.SharePoint)
                {
                    if (regressionProfile.API == RegressionAPI.CSOM)
                    {
                        // csom related options
                        solutionOptions.Add(DefaultOptions.SharePoint.Api.CSOM);
                        solutionOptions.Add(DefaultOptions.SharePoint.Edition.Standard);
                        solutionOptions.Add(DefaultOptions.SharePoint.Version.SP2013);

                        var siteUrl = SP2013RootWebUrl;

                        // checking correct model
                        if (regressionProfile.ModelLevel == RegressinModelLevel.Site)
                        {
                            siteUrl = SP2013RootWebUrl;
                        }
                        else if (regressionProfile.ModelLevel == RegressinModelLevel.Web)
                        {
                            siteUrl = SP2013RootWebUrl;
                        }
                        else if (regressionProfile.ModelLevel == RegressinModelLevel.Subweb)
                        {
                            siteUrl = SP2013SubWebUrl;
                        }
                        else
                        {
                            throw new NotImplementedException(
                                string.Format("Unsupported ModelLevel type:[{0}]",
                                              regressionProfile.ModelLevel));
                        }

                        solutionOptions.Add(new OptionValue
                        {
                            Name  = DefaultOptions.Site.Url.Id,
                            Value = siteUrl
                        });

                        WithCISharePointClientContext(siteUrl, context =>
                        {
                            metapackDeployment(context, ciPackage, solutionOptions);
                        });
                    }
                    else if (regressionProfile.API == RegressionAPI.SSOM)
                    {
                        // csom related options
                        solutionOptions.Add(DefaultOptions.SharePoint.Api.SSOM);
                        solutionOptions.Add(DefaultOptions.SharePoint.Edition.Standard);
                        solutionOptions.Add(DefaultOptions.SharePoint.Version.SP2013);

                        var siteUrl = SP2013RootWebUrl;

                        // checking correct model
                        if (regressionProfile.ModelLevel == RegressinModelLevel.Site)
                        {
                            siteUrl = SP2013RootWebUrl;
                        }
                        else if (regressionProfile.ModelLevel == RegressinModelLevel.Web)
                        {
                            siteUrl = SP2013RootWebUrl;
                        }
                        else if (regressionProfile.ModelLevel == RegressinModelLevel.Subweb)
                        {
                            siteUrl = SP2013SubWebUrl;
                        }
                        else
                        {
                            throw new NotImplementedException(
                                string.Format("Unsupported ModelLevel type:[{0}]",
                                              regressionProfile.ModelLevel));
                        }

                        solutionOptions.Add(new OptionValue
                        {
                            Name  = DefaultOptions.Site.Url.Id,
                            Value = siteUrl
                        });

                        WithCISharePointClientContext(siteUrl, context =>
                        {
                            metapackDeployment(context, ciPackage, solutionOptions);
                        });
                    }
                    else
                    {
                        throw new NotImplementedException(
                            string.Format("Unsupported API type:[{0}]",
                                          regressionProfile.API));
                    }
                }
                else
                {
                    throw new NotImplementedException(
                        string.Format("Unsupported Sandbox type:[{0}]",
                                      regressionProfile.Sandbox));
                }
            });
        }
Esempio n. 9
0
 private void Internal_Can_Deploy_SolutionPackage_On_O365_Web_CSOM(MetaPackServiceContext s)
 {
     Internal_Can_Deploy_SolutionPackage_On_O365_Web_CSOM(s, false);
 }
Esempio n. 10
0
 public void Internal_Can_Deploy_SolutionPackage_On_SharePoint_Web_SSOM(MetaPackServiceContext s)
 {
     Internal_Can_Deploy_SolutionPackage_On_SharePoint_Web_SSOM(s, false);
 }