Beispiel #1
0
        ////This test sets up projects for further manual tests. It generates legacy projects with all pages and features.
#pragma warning disable xUnit1026 // Theory methods should use all of their parameters
        public async Task GenerateLegacyProjectWithAllPagesAndFeaturesAsync(string projectType, string framework, string platform, string language)
#pragma warning restore xUnit1026 // Theory methods should use all of their parameters
        {
            var fixture = _fixture as BuildRightClickWithLegacyFixture;

            if (language == ProgrammingLanguages.VisualBasic)
            {
                fixture.ChangeTemplatesSource(fixture.VBSource, language, Platforms.Uwp);
            }

            var projectName = $"{ProgrammingLanguages.GetShortProgrammingLanguage(language)}{ShortProjectType(projectType)}{framework}AllLegacy";

            Func <ITemplateInfo, bool> selector =
                t => t.GetTemplateType() == TemplateType.Project &&
                t.GetProjectTypeList().Contains(projectType) &&
                t.GetFrameworkList().Contains(framework) &&
                !t.GetIsHidden() &&
                t.GetLanguage() == language;

            Func <ITemplateInfo, bool> templateSelector =
                t => (t.GetTemplateType() == TemplateType.Page || t.GetTemplateType() == TemplateType.Feature) &&
                t.GetFrameworkList().Contains(framework) &&
                t.GetPlatform() == platform &&
                !t.GetIsHidden();

            var projectPath = await AssertGenerateProjectAsync(selector, projectName, projectType, framework, platform, language, templateSelector, BaseGenAndBuildFixture.GetDefaultName, false);
        }
 public RemoteTemplatesSource(string platform, string language, string installedPackagePath, IDigitalSignatureService digitalSignatureService)
 {
     Platform             = platform;
     Language             = ProgrammingLanguages.GetShortProgrammingLanguage(language);
     InstalledPackagePath = installedPackagePath;
     _templatePackage     = new TemplatePackage(digitalSignatureService);
     CanGetNewContent     = digitalSignatureService.CanVerifySignatures;
 }
        public void TemplateSourceConfigTest_ResolveFile()
        {
            var configFile = Path.GetFullPath(@".\Packaging\SampleConfig.json");

            var config = TemplatesSourceConfig.LoadFromFile(configFile);

            var package = config.ResolvePackage(new Version(1, 3), Platforms.Uwp, ProgrammingLanguages.GetShortProgrammingLanguage(ProgrammingLanguages.CSharp));

            Assert.Equal("UWP.CS.Templates_1.2.3.4.mstx", package.Name);
        }
Beispiel #4
0
        ////This test sets up projects for further manual tests. It generates legacy projects with all pages and features.
#pragma warning disable xUnit1026 // Theory methods should use all of their parameters
        public async Task Build_All_Legacy_UwpAsync(string projectType, string framework, string platform, string language)
#pragma warning restore xUnit1026 // Theory methods should use all of their parameters
        {
            var fixture = _fixture as BuildRightClickWithLegacyVBFixture;

            var projectName = $"{ProgrammingLanguages.GetShortProgrammingLanguage(language)}{ShortProjectType(projectType)}{framework}AllLegacy";

            bool templateSelector(ITemplateInfo t) => t.GetTemplateType().IsItemTemplate() &&
            (t.GetProjectTypeList().Contains(projectType) || t.GetProjectTypeList().Contains(All)) &&
            (t.GetFrontEndFrameworkList().Contains(framework) || t.GetFrontEndFrameworkList().Contains(All)) &&
            t.GetPlatform() == platform &&
            !t.GetIsHidden();

            var projectPath = await AssertGenerateProjectAsync(projectName, projectType, framework, platform, language, templateSelector, BaseGenAndBuildFixture.GetDefaultName);
        }
        public static void PublishContent(RemoteSourcePublishOptions options, TextWriter output, TextWriter error)
        {
            try
            {
                var shortLanguage = ProgrammingLanguages.GetShortProgrammingLanguage(options.Language);
                output.WriteCommandHeader($"Publishing {options.File} for environment {options.Env.ToString()} ({options.StorageAccount}), Platform: {options.Platform}, Language: {shortLanguage} and WizardVersion {options.WizardVersion}");
                output.WriteCommandText("Uploading template package...");
                output.WriteCommandText(RemoteSource.UploadTemplatesContent(options.StorageAccount, options.AccountKey, options.Env.ToString().ToLowerInvariant(), options.File, options.Version, options.Platform, shortLanguage, options.WizardVersion));

                PublishUpdatedRemoteSourceConfig(options, output);
            }
            catch (Exception ex)
            {
                error.WriteException(ex, $"Unable to publish the file {options.File} content to the specified environment container.");
            }
        }
        public static void DownloadContent(RemoteSourceDownloadOptions options, TextWriter output, TextWriter error)
        {
            try
            {
                var shortLanguage = ProgrammingLanguages.GetShortProgrammingLanguage(options.Language);

                output.WriteCommandHeader($"Downloading templates content from environment {options.Env.ToString()} ({options.StorageAccount})");

                TemplatesSourceConfig config = GetConfigFromCdn(options.Env);

                TemplatesPackageInfo package = null;
                if (options.Version != null)
                {
                    package = ResolvePackageForVersion(config, options.Version, options.Platform, shortLanguage, output);
                }
                else
                {
                    package = config.Latest;
                }

                if (package != null)
                {
                    Fs.EnsureFolderExists(options.Destination);

                    var result = RemoteSource.DownloadCdnElement(Environments.CdnUrls[options.Env], package.Name, options.Destination);
                    output.WriteLine();
                    output.WriteCommandText($"Successfully downloaded '{result}'");
                    output.WriteLine();
                }
                else
                {
                    output.WriteLine();
                    output.WriteCommandText($"Package not found for the version '{options.Version}', platform '{options.Platform}' and laguage '{options.Language}'");
                    output.WriteLine();
                }
            }
            catch (Exception ex)
            {
                error.WriteException(ex, $"Unable to download the file content from the specified environment.");
            }
        }
 public RemoteTemplatesSource(string platform, string language)
 {
     Platform = platform;
     Language = ProgrammingLanguages.GetShortProgrammingLanguage(language);
 }