コード例 #1
0
ファイル: Solution.cs プロジェクト: RoryVL/roslyn
        public Project AddProject(string projectName, ProjectTemplate projectTemplate, ProjectLanguage projectLanguage)
        {
            var projectPath = Path.Combine(DirectoryName, projectName);
            var projectTemplatePath = GetProjectTemplatePath(projectTemplate, projectLanguage);

            var dteProject = IntegrationHelper.RetryRpcCall(() => _dteSolution.AddFromTemplate(projectTemplatePath, projectPath, projectName, Exclusive: false));

            if (dteProject == null)
            {
                dteProject = GetDteProject(projectName);
            }

            return new Project(dteProject, this, projectLanguage);
        }
コード例 #2
0
        public async Task InstallPackageFromPMCWithNoAutoRestoreVerifyAssetsFileAsync(ProjectTemplate projectTemplate)
        {
            // Arrange
            EnsureVisualStudioHost();

            using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger, noAutoRestore: true, addNetStandardFeeds: true))
            {
                var packageName    = "TestPackage";
                var packageVersion = "1.0.0";
                await CommonUtility.CreatePackageInSourceAsync(testContext.PackageSource, packageName, packageVersion);

                var nugetConsole = GetConsole(testContext.Project);

                nugetConsole.InstallPackageFromPMC(packageName, packageVersion);

                CommonUtility.AssertPackageInAssetsFile(VisualStudio, testContext.Project, packageName, packageVersion, XunitLogger);
            }
        }
コード例 #3
0
 internal void createNewProject(string projectDirectory, bool deleteOld, ProjectTemplate projectTemplate)
 {
     editorController.createNewProject(projectDirectory, deleteOld, projectTemplate);
 }
コード例 #4
0
        // icon view event handlers
        void SelectedIndexChange(object sender, EventArgs e)
        {
            try {
                btn_new.Sensitive               = true;
                txt_name.Sensitive              = true;
                txt_subdirectory.Sensitive      = true;
                chk_combine_directory.Sensitive = true;
                entry_location.Sensitive        = true;

                if (templateView.CurrentlySelected != null)
                {
                    ProjectTemplate ptemplate = (ProjectTemplate)templateView.CurrentlySelected;
                    lbl_template_descr.Text   = StringParserService.Parse(ptemplate.Description);
                    labelTemplateTitle.Markup = "<b>" + GLib.Markup.EscapeText(ptemplate.Name) + "</b>";

                    if (ptemplate.SolutionDescriptor.EntryDescriptors.Length == 0)
                    {
                        txt_subdirectory.Sensitive      = false;
                        chk_combine_directory.Sensitive = false;
                        lbl_subdirectory.Sensitive      = false;
                        btn_new.Label = Gtk.Stock.Ok;
                    }
                    else
                    {
                        lbl_subdirectory.Sensitive = true;
                        txt_subdirectory.Text      = txt_name.Text;

                        ProjectCreateInformation cinfo = CreateProjectCreateInformation();
                        if (ptemplate.HasItemFeatures(parentFolder, cinfo))
                        {
                            btn_new.Label = Gtk.Stock.GoForward;
                        }
                        else
                        {
                            btn_new.Label = Gtk.Stock.Ok;
                        }
                    }
                }
                else
                {
                    lbl_template_descr.Text = String.Empty;
                    labelTemplateTitle.Text = "";
                }

                PathChanged(null, null);
            } catch (Exception ex) {
                txt_name.Sensitive              = false;
                btn_new.Sensitive               = false;
                txt_subdirectory.Sensitive      = false;
                chk_combine_directory.Sensitive = false;
                entry_location.Sensitive        = false;

                while (ex is TargetInvocationException)
                {
                    ex = ((TargetInvocationException)ex).InnerException;
                }

                if (ex is UserException)
                {
                    var user = (UserException)ex;
                    MessageService.ShowError(user.Message, user.Details);
                }
                else
                {
                    MessageService.ShowException(ex);
                };
            }
        }
コード例 #5
0
 public TemplateItem(ProjectTemplate template) : base(StringParser.Parse(template.Name))
 {
     this.template = template;
     ImageIndex    = 0;
 }
コード例 #6
0
 public TemplateItem(ProjectTemplate template) : base(template.DisplayName)
 {
     this.template = template;
     ImageIndex    = 0;
 }
コード例 #7
0
        public async Task WithExpiredAuthorCertificateAfterCountersigning_InstallFromPMCForPC_SucceedAsync(ProjectTemplate projectTemplate)
        {
            // Arrange
            EnsureVisualStudioHost();

            var timestampService = await _fixture.GetDefaultTrustedTimestampServiceAsync();

            using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger))
                using (var trustedCert = _fixture.TrustedRepositoryTestCertificate)
                    using (var trustedExpiringTestCert = SigningTestUtility.GenerateTrustedTestCertificateThatExpiresIn5Seconds())
                    {
                        XunitLogger.LogInformation("Creating package");
                        var package = CommonUtility.CreatePackage("ExpiredTestPackage", "1.0.0");

                        XunitLogger.LogInformation("Signing and countersigning package");
                        var expiredTestPackage   = CommonUtility.AuthorSignPackage(package, trustedExpiringTestCert.Source.Cert);
                        var countersignedPackage = CommonUtility.RepositoryCountersignPackage(
                            expiredTestPackage,
                            trustedCert.Source.Cert,
                            new Uri("https://v3serviceIndexUrl.test/api/index.json"),
                            packageOwners: null,
                            timestampProviderUrl: timestampService.Url);

                        await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, expiredTestPackage);

                        XunitLogger.LogInformation("Waiting for package to expire");
                        SigningUtility.WaitForCertificateToExpire(trustedExpiringTestCert.Source.Cert);

                        var nugetConsole = GetConsole(testContext.Project);

                        nugetConsole.InstallPackageFromPMC(expiredTestPackage.Id, expiredTestPackage.Version);
                        testContext.Project.Build();
                        testContext.NuGetApexTestService.WaitForAutoRestore();

                        CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.Project, expiredTestPackage.Id, expiredTestPackage.Version, XunitLogger);
                    }
        }
コード例 #8
0
        public async Task WithExpiredAuthorCertificateAtCountersigning_InstallFromPMCForPC_WarnAsync(ProjectTemplate projectTemplate)
        {
            // Arrange
            EnsureVisualStudioHost();

            var timestampService = await _fixture.GetDefaultTrustedTimestampServiceAsync();

            using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger))
                using (var trustedCert = _fixture.TrustedRepositoryTestCertificate)
                    using (var trustedExpiringTestCert = SigningTestUtility.GenerateTrustedTestCertificateThatExpiresIn5Seconds())
                    {
                        XunitLogger.LogInformation("Creating package");
                        var package = CommonUtility.CreatePackage("ExpiredTestPackage", "1.0.0");

                        XunitLogger.LogInformation("Signing package");
                        var expiredTestPackage = CommonUtility.AuthorSignPackage(package, trustedExpiringTestCert.Source.Cert);
                        await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, expiredTestPackage);

                        var packageFullName = Path.Combine(testContext.PackageSource, expiredTestPackage.PackageName);

                        XunitLogger.LogInformation("Waiting for package to expire");
                        SigningUtility.WaitForCertificateToExpire(trustedExpiringTestCert.Source.Cert);

                        XunitLogger.LogInformation("Countersigning package");
                        var countersignedPackage = await SignedArchiveTestUtility.RepositorySignPackageAsync(
                            new X509Certificate2(trustedCert.Source.Cert),
                            packageFullName,
                            testContext.PackageSource,
                            new Uri("https://v3serviceIndexUrl.test/api/index.json"),
                            timestampService.Url);

                        File.Copy(countersignedPackage, packageFullName, overwrite: true);
                        File.Delete(countersignedPackage);

                        var nugetConsole = GetConsole(testContext.Project);

                        nugetConsole.InstallPackageFromPMC(expiredTestPackage.Id, expiredTestPackage.Version);

                        // TODO: Fix bug where no warnings are shown when package is untrusted but still installed
                        //nugetConsole.IsMessageFoundInPMC("expired certificate").Should().BeTrue("expired certificate warning");
                        CommonUtility.AssetPackageInPackagesConfig(VisualStudio, testContext.Project, expiredTestPackage.Id, expiredTestPackage.Version, XunitLogger);
                    }
        }
コード例 #9
0
ファイル: Solution.cs プロジェクト: swaroop-sridhar/roslyn
 // TODO: Adjust language name based on whether we are using a web template
 private string GetProjectTemplatePath(ProjectTemplate projectTemplate, ProjectLanguage projectLanguage)
     => IntegrationHelper.RetryRpcCall(() => _dteSolution.GetProjectTemplate(_projectTemplates[projectTemplate], ProjectLanguages[projectLanguage]));
コード例 #10
0
 public ProjectTemplateViewModel(ProjectTemplate projectTemplate)
 {
     Name = projectTemplate.Name;
 }
コード例 #11
0
 private void SchoolTemplate_Selected(object sender, RoutedEventArgs e)
 {
     TemplateListBox.BorderBrush = (SolidColorBrush) new BrushConverter().ConvertFrom("#ABADB3");
     SchoolTemplate.Background   = (SolidColorBrush) new BrushConverter().ConvertFrom("#FFFFFF");
     template = ProjectTemplate.SchoolTemplate;
 }
コード例 #12
0
        public async Task UpdatePackageForPR_PackageNamespace_WithMultipleFeedsWithIdenticalPackages_InstallsCorrectPackage(ProjectTemplate projectTemplate)
        {
            // Arrange
            EnsureVisualStudioHost();

            using var simpleTestPathContext = new SimpleTestPathContext();
            string solutionDirectory = simpleTestPathContext.SolutionRoot;
            var    packageName       = "Contoso.A";
            var    packageVersion1   = "1.0.0";
            var    packageVersion2   = "2.0.0";

            var opensourceRepositoryPath = Path.Combine(solutionDirectory, "OpensourceRepository");

            Directory.CreateDirectory(opensourceRepositoryPath);

            await CommonUtility.CreateNetFrameworkPackageInSourceAsync(opensourceRepositoryPath, packageName, packageVersion1);

            await CommonUtility.CreateNetFrameworkPackageInSourceAsync(opensourceRepositoryPath, packageName, packageVersion2);

            var privateRepositoryPath = Path.Combine(solutionDirectory, "PrivateRepository");

            Directory.CreateDirectory(privateRepositoryPath);

            await CommonUtility.CreateNetFrameworkPackageInSourceAsync(privateRepositoryPath, packageName, packageVersion1);

            await CommonUtility.CreateNetFrameworkPackageInSourceAsync(privateRepositoryPath, packageName, packageVersion2);

            //Create nuget.config with Package namespace filtering rules.
            CommonUtility.CreateConfigurationFile(Path.Combine(solutionDirectory, "NuGet.config"), $@"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
    <packageSources>
        <add key=""ExternalRepository"" value=""{opensourceRepositoryPath}"" />
        <add key=""PrivateRepository"" value=""{privateRepositoryPath}"" />
    </packageSources>
    <packageSourceMapping>
        <packageSource key=""externalRepository"">
            <package pattern=""External.*"" />
            <package pattern=""Others.*"" />
        </packageSource>
        <packageSource key=""PrivateRepository"">
            <package pattern=""Contoso.*"" />
            <package pattern=""Test.*"" />
        </packageSource>
        <packageSource key=""nuget"">
            <package pattern=""Microsoft.*"" />
            <package pattern=""NetStandard*"" />
        </packageSource>
    </packageSourceMapping>
</configuration>");

            using var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger, noAutoRestore: false, addNetStandardFeeds: true, simpleTestPathContext: simpleTestPathContext);
            var solutionService = VisualStudio.Get <SolutionService>();
            var nugetConsole    = GetConsole(testContext.Project);

            //Pre-conditions
            nugetConsole.InstallPackageFromPMC(packageName, packageVersion1);
            testContext.SolutionService.Build();
            VisualStudio.AssertNuGetOutputDoesNotHaveErrors();
            VisualStudio.HasNoErrorsInOutputWindows().Should().BeTrue();
            nugetConsole.Clear();

            // Act
            nugetConsole.UpdatePackageFromPMC(packageName, packageVersion2);

            // Assert
            var expectedMessage = $"Installed {packageName} {packageVersion2} from {privateRepositoryPath}";

            nugetConsole.IsMessageFoundInPMC(expectedMessage).Should().BeTrue(because: nugetConsole.GetText());
            VisualStudio.AssertNuGetOutputDoesNotHaveErrors();
            VisualStudio.HasNoErrorsInOutputWindows().Should().BeTrue();

            nugetConsole.Clear();
            solutionService.Save();
        }
コード例 #13
0
        public async Task WithSourceMappingEnabled_InstallPackageFromPMUIFromExpectedSource_Succeeds(ProjectTemplate projectTemplate)
        {
            // Arrange
            EnsureVisualStudioHost();

            using (var simpleTestPathContext = new SimpleTestPathContext())
            {
                string solutionDirectory     = simpleTestPathContext.SolutionRoot;
                var    privateRepositoryPath = Path.Combine(solutionDirectory, "PrivateRepository");
                Directory.CreateDirectory(privateRepositoryPath);
                var externalRepositoryPath = Path.Combine(solutionDirectory, "ExternalRepository");
                Directory.CreateDirectory(externalRepositoryPath);

                var packageName    = "Contoso.a";
                var packageVersion = "1.0.0";

                await CommonUtility.CreatePackageInSourceAsync(privateRepositoryPath, packageName, packageVersion);

                await CommonUtility.CreatePackageInSourceAsync(externalRepositoryPath, packageName, packageVersion);


                // Create nuget.config with Package source mapping filtering rules before project is created.
                CommonUtility.CreateConfigurationFile(Path.Combine(solutionDirectory, "NuGet.Config"), $@"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
    <packageSources>
        <add key=""ExternalRepository"" value=""{externalRepositoryPath}"" />
        <add key=""PrivateRepository"" value=""{privateRepositoryPath}"" />
    </packageSources>
    <packageSourceMapping>
        <packageSource key=""externalRepository"">
            <package pattern=""External.*"" />
            <package pattern=""Others.*"" />
        </packageSource>
        <packageSource key=""PrivateRepository"">
            <package pattern=""contoso.*"" />
            <package pattern=""Test.*"" />
        </packageSource>
        <packageSource key=""nuget"">
            <package pattern=""Microsoft.*"" />
            <package pattern=""NetStandard*"" />
        </packageSource>
    </packageSourceMapping>
</configuration>");

                using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger, addNetStandardFeeds: true, simpleTestPathContext: simpleTestPathContext))
                {
                    VisualStudio.AssertNoErrors();

                    // Act
                    CommonUtility.OpenNuGetPackageManagerWithDte(VisualStudio, XunitLogger);
                    var nugetTestService = GetNuGetTestService();
                    var uiwindow         = nugetTestService.GetUIWindowfromProject(testContext.SolutionService.Projects[0]);
                    uiwindow.InstallPackageFromUI(packageName, packageVersion);

                    // Assert
                    VisualStudio.AssertNuGetOutputDoesNotHaveErrors();
                    CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.SolutionService.Projects[0], packageName, packageVersion, XunitLogger);
                    Assert.Contains($"Installed {packageName} {packageVersion} from {privateRepositoryPath}", GetPackageManagerOutputWindowPaneText());
                }
            }
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: vol16bit/xenko
        private static void GenerateUnitTestProject(string outputDirectory, string templateFile, string name, string projectNamespace)
        {
            var projectTemplate = ProjectTemplate.Load(templateFile);

            // Force reference to Xenko.Assets (to have acess to SolutionPlatform)
            projectTemplate.Assemblies.Add(typeof(GraphicsProfile).Assembly.FullName);
            projectTemplate.Assemblies.Add(typeof(XenkoConfig).Assembly.FullName);

            var options = new Dictionary <string, object>();

            // When generating over an existing set of files, retrieve the existing IDs
            // for better incrementality
            Guid projectGuid, assetId;

            GetExistingGuid(outputDirectory, name + ".Windows.csproj", out projectGuid);
            GetExistingAssetId(outputDirectory, name + ".xkpkg", out assetId);

            var session = new PackageSession();
            var result  = new LoggerResult();

            var templateGeneratorParameters = new SessionTemplateGeneratorParameters();

            templateGeneratorParameters.OutputDirectory = outputDirectory;
            templateGeneratorParameters.Session         = session;
            templateGeneratorParameters.Name            = name;
            templateGeneratorParameters.Logger          = result;
            templateGeneratorParameters.Description     = new TemplateDescription();
            templateGeneratorParameters.Id = assetId;

            if (!PackageUnitTestGenerator.Default.PrepareForRun(templateGeneratorParameters).Result)
            {
                Console.WriteLine(@"Error generating package: PackageUnitTestGenerator.PrepareForRun returned false");
                return;
            }
            if (!PackageUnitTestGenerator.Default.Run(templateGeneratorParameters))
            {
                Console.WriteLine(@"Error generating package: PackageUnitTestGenerator.Run returned false");
                return;
            }
            if (result.HasErrors)
            {
                Console.WriteLine($"Error generating package: {result.ToText()}");
                return;
            }

            var package = session.LocalPackages.Single();

            var previousCurrent = session.CurrentPackage;

            session.CurrentPackage = package;

            // Compute Xenko Sdk relative path
            // We are supposed to be in standard output binary folder, so Xenko root should be at ..\..
            var xenkoPath         = UPath.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), new UDirectory(@"..\.."));
            var xenkoRelativePath = new UDirectory(xenkoPath)
                                    .MakeRelative(outputDirectory)
                                    .ToString()
                                    .Replace('/', '\\');

            xenkoRelativePath = xenkoRelativePath.TrimEnd('\\');

            options["Namespace"]           = projectNamespace ?? name;
            options["Package"]             = package;
            options["Platforms"]           = new List <SolutionPlatform>(AssetRegistry.SupportedPlatforms);
            options["XenkoSdkRelativeDir"] = xenkoRelativePath;

            // Generate project template
            result = projectTemplate.Generate(outputDirectory, name, projectGuid, options);
            if (result.HasErrors)
            {
                Console.WriteLine("Error generating solution: {0}", result.ToText());
                return;
            }

            var sharedProfile = package.Profiles.FindSharedProfile();

            // Setup the assets folder
            Directory.CreateDirectory(UPath.Combine(outputDirectory, (UDirectory)"Assets/Shared"));

            // Add Windows test as Shared library
            var projectWindowsRef = new ProjectReference(projectGuid, UPath.Combine(outputDirectory, (UFile)(name + ".Windows.csproj")), SiliconStudio.Assets.ProjectType.Library);

            sharedProfile.ProjectReferences.Add(projectWindowsRef);

            // Generate executable projects for each platform
            foreach (var platform in AssetRegistry.SupportedPlatforms)
            {
                var platformProfile = new PackageProfile(platform.Name)
                {
                    Platform = platform.Type
                };
                platformProfile.AssetFolders.Add(new AssetFolder("Assets/" + platform.Name));

                // Log progress
                var projectName = name + "." + platform.Type;

                // Create project reference
                var projectPlatformRef = new ProjectReference(projectGuid, UPath.Combine(outputDirectory, (UFile)(projectName + ".csproj")), SiliconStudio.Assets.ProjectType.Executable);

                platformProfile.ProjectReferences.Add(projectPlatformRef);

                package.Profiles.Add(platformProfile);
            }

            session.CurrentPackage = previousCurrent;

            session.Save(result);
            if (result.HasErrors)
            {
                Console.WriteLine("Error saving package: {0}", result.ToText());
                return;
            }
        }
コード例 #15
0
 internal StubbleProjectGeneratorBuilder WithProjectTemplate(ProjectTemplate template)
 {
     _registry.Setup(reg => reg.Lookup(It.IsAny <ProjectSpec>())).Returns(template);
     return(this);
 }
コード例 #16
0
 public void Dispose()
 {
     testProject1         = _dummyApplicationDbContext.testProject;
     testProjectTemplate1 = _dummyApplicationDbContext.projectTemplate1;
     testGroup1           = _dummyApplicationDbContext.testGroup;
 }
コード例 #17
0
ファイル: Solution.cs プロジェクト: AlexanderSher/roslyn
 // TODO: Adjust language name based on whether we are using a web template
 private string GetProjectTemplatePath(ProjectTemplate projectTemplate, ProjectLanguage projectLanguage)
 => _dteSolution.GetProjectTemplate(ProjectTemplateName[projectTemplate], ProjectLanguageName[projectLanguage]);
コード例 #18
0
        public async Task WithExpiredAuthorCertificate_ExpiredRepoCertificate_InstallFromPMCForPC_WarnAsync(ProjectTemplate projectTemplate)
        {
            // Arrange
            EnsureVisualStudioHost();

            using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger))
                using (var trustedExpiringTestCert = SigningTestUtility.GenerateTrustedTestCertificateThatExpiresIn5Seconds())
                {
                    XunitLogger.LogInformation("Creating package");
                    var package = CommonUtility.CreatePackage("ExpiredTestPackage", "1.0.0");

                    XunitLogger.LogInformation("Signing and countersigning package");
                    var expiredTestPackage   = CommonUtility.AuthorSignPackage(package, trustedExpiringTestCert.Source.Cert);
                    var countersignedPackage = CommonUtility.RepositoryCountersignPackage(
                        expiredTestPackage,
                        trustedExpiringTestCert.Source.Cert,
                        new Uri("https://v3serviceIndexUrl.test/api/index.json"));

                    await SimpleTestPackageUtility.CreatePackagesAsync(testContext.PackageSource, expiredTestPackage);

                    XunitLogger.LogInformation("Waiting for package to expire");
                    SigningUtility.WaitForCertificateToExpire(trustedExpiringTestCert.Source.Cert);

                    var nugetConsole = GetConsole(testContext.Project);

                    nugetConsole.InstallPackageFromPMC(expiredTestPackage.Id, expiredTestPackage.Version);
                    testContext.Project.Build();
                    testContext.NuGetApexTestService.WaitForAutoRestore();

                    // TODO: Fix bug where no warnings are shown when package is untrusted but still installed
                    //nugetConsole.IsMessageFoundInPMC("expired certificate").Should().BeTrue("expired certificate warning");
                    CommonUtility.AssertPackageReferenceExists(VisualStudio, testContext.Project, expiredTestPackage.Id, expiredTestPackage.Version, XunitLogger);
                }
        }
コード例 #19
0
ファイル: SolutionWizard.cs プロジェクト: LogoFX/tools
        private void AddProject(SolutionFolder parent, ProjectTemplate project, IList<Project> projects)
        {
            var projectFullName = project.FileName;
            var projectFileName = Path.GetFileName(projectFullName);
            var projectDirectory = Path.GetDirectoryName(projectFullName);

            Debug.Assert(projectDirectory != null, "projectDirectory != null");

            var directoryName = Path.GetDirectoryName(projectDirectory);
            var path1 = Path.GetDirectoryName(directoryName);

            Debug.Assert(path1 != null, "path1 != null");

            var newProjectDirectory = Path.Combine(path1, Path.GetFileName(projectDirectory));

            Debug.Assert(projectFileName != null, "projectFileName != null");

            var newProjectFullName = Path.Combine(newProjectDirectory, projectFileName);

            CopyDirectory(projectDirectory, newProjectDirectory);

            var addedProject = parent == null
                ? GetSolution().AddFromFile(newProjectFullName)
                : parent.AddFromFile(newProjectFullName);

            projects.Add(addedProject);
        }
コード例 #20
0
        /// <summary>
        /// Creates a new project file with the specified parameters and saves the file.
        /// </summary>
        public string CreateProject(string mapName, string author, string gameID, ProjectTemplate template, string filename)
        {
            // TODO: Have more specific error handling here.
            try
            {
                string fullFilename = filename;
                if (!fullFilename.EndsWith(".pproj"))
                {
                    fullFilename += ".pproj";
                }

                gameDefinition = Prometheus.Instance.GetGameDefinitionByGameID(gameID);

                string projectFolder = Application.StartupPath + "\\Games\\" + gameDefinition.GameID + "\\Projects\\" + filename;
                string tagsFolder    = projectFolder + "\\Tags";

                // Create the proper folders, if they do not already exist.
                if (!Directory.Exists(tagsFolder))
                {
                    Directory.CreateDirectory(tagsFolder);                        // Project folder will auto-create.
                }
                // We must create a new instance of the Scenario tag and save it to the Tags folder.
                // TODO: In the future, this will need to be based on an existing scenario_structure_bsp tag.
                // The functioanlity of adding the bsp reference will need to be abstracted into the
                // Scenario base.

                // TODO: We should have the option to create the project based on an existing scenario file.
                // TODO: This will require a tag browser dialog.

                Type t      = gameDefinition.TypeTable.LocateEntryByFourCC("scnr").TagType;
                Tag  newTag = (Tag)Activator.CreateInstance(t);
                newTag.New();

                // Create the folders
                string scenarioFolder = tagsFolder + "\\levels\\" + filename;
                if (!Directory.Exists(scenarioFolder))
                {
                    Directory.CreateDirectory(scenarioFolder);
                }
                BinaryWriter writer = new BinaryWriter(new FileStream(scenarioFolder + "\\" + filename + ".scenario", FileMode.Create));
                writer.Write(newTag.Save());
                writer.Close();

                // NOTE: This is temporary, we will use the TBD to get this file eventually.
                scenarioTag = "levels\\" + filename + "\\" + filename + ".scenario";

                ProjectFile project = new ProjectFile(mapName, author, gameDefinition, template);

                // TODO: Implement a method that will automatically check to see if an item exists before adding it,
                // and update it instead.  CollectionBase might be better for this, as lookups can be
                // done using a case-insensitive comparison.
                TagPath scenarioPath = new TagPath("levels\\" + filename + "\\" + filename + ".scenario", "", TagLocation.Project);
                project.AddTemplateReference(scenarioPath, "Scenario");
                string fullProjectFileName = projectFolder + "\\" + fullFilename;
                SaveProject(fullProjectFileName, project);
                return(fullProjectFileName);
            }
            catch (Exception ex)
            {
                throw new CreateProjectFailedException("Failed to create project: " + filename, ex);
            }
        }
コード例 #21
0
        public async Task InitializeData()
        {
            _dbContext.Database.EnsureDeleted();
            if (_dbContext.Database.EnsureCreated())
            {
                //seeding
                AppUser leraar = new AppUser
                {
                    UserName = "******",
                    Email    = "*****@*****.**"
                };

                await CreateUser(leraar, "P@ssword1");



                // category template
                CategoryTemplate ct1 = new CategoryTemplate
                {
                    CategoryName  = "default categorytemplate",
                    AddedByGO     = true,
                    CategoryDescr = "default categorytemplate descr"
                };

                //application domain

                ApplicationDomain energie = new ApplicationDomain
                {
                    ApplicationDomainName  = "Energie",
                    ApplicationDomainDescr = "Alles over energie"
                };

                ApplicationDomain informatie = new ApplicationDomain
                {
                    ApplicationDomainName  = "Informatie & communicactie",
                    ApplicationDomainDescr = "Alles over informatie & communicactie"
                };

                ApplicationDomain constructie = new ApplicationDomain
                {
                    ApplicationDomainName  = "Constructie",
                    ApplicationDomainDescr = "Alles over constructie"
                };

                ApplicationDomain transport = new ApplicationDomain
                {
                    ApplicationDomainName  = "Transport",
                    ApplicationDomainDescr = "Alles over transport"
                };

                ApplicationDomain biochemie = new ApplicationDomain
                {
                    ApplicationDomainName  = "Biochemie",
                    ApplicationDomainDescr = "Alles over biochemie"
                };


                //school
                School schoolGO = new School
                {
                    Name   = "Go school",
                    Email  = "*****@*****.**",
                    TelNum = "049746382",
                    Adres  = new Adres
                    {
                        Straat     = "straat",
                        Postcode   = "8490",
                        Huisnummer = "5",
                        Plaats     = "Brugge"
                    }
                };

                _dbContext.Add(ct1);
                _dbContext.Add(schoolGO);
                _dbContext.Add(energie);
                _dbContext.Add(informatie);
                _dbContext.Add(constructie);
                _dbContext.Add(transport);
                _dbContext.Add(biochemie);
                _dbContext.SaveChanges();

                //classroom
                ClassRoom cr = new ClassRoom
                {
                    Name     = "Klas 1",
                    SchoolId = schoolGO.SchoolId
                };
                ClassRoom cr2 = new ClassRoom
                {
                    Name     = "Klas 2",
                    SchoolId = schoolGO.SchoolId
                };
                schoolGO.ClassRooms.Add(cr);
                schoolGO.ClassRooms.Add(cr2);

                #region ProductTemplates

                ProductTemplate pt1 = new ProductTemplate
                {
                    ProductName  = "Karton",
                    Description  = "Dit is karton",
                    AddedByGO    = true,
                    ProductImage = "https://www.manutan.be/img/S/GRP/ST/AIG2166048.jpg",
                    Score        = 9,
                    HasMultipleDisplayVariations = true,
                    CategoryTemplateId           = ct1.CategoryTemplateId,
                    SchoolId = schoolGO.SchoolId,
                    ProductVariationTemplates = new List <ProductVariationTemplate>
                    {
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Algemene beschrijving karton",
                            ESchoolGrade = ESchoolGrade.ALGEMEEN
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Eerste graad beschrijving karton",
                            ESchoolGrade = ESchoolGrade.EERSTE
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Tweede graad beschrijving karton",
                            ESchoolGrade = ESchoolGrade.TWEEDE
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Derde graad beschrijving karton",
                            ESchoolGrade = ESchoolGrade.DERDE
                        }
                    }
                };

                ProductTemplate pt2 = new ProductTemplate
                {
                    ProductName  = "Lijm",
                    Description  = "Dit is lijm",
                    AddedByGO    = true,
                    ProductImage = "https://www.manutan.be/img/S/GRP/ST/AIG2399133.jpg",
                    Score        = 6,
                    HasMultipleDisplayVariations = true,
                    CategoryTemplateId           = ct1.CategoryTemplateId,
                    SchoolId = schoolGO.SchoolId,
                    ProductVariationTemplates = new List <ProductVariationTemplate>
                    {
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Algemene beschrijving Lijm",
                            ESchoolGrade = ESchoolGrade.ALGEMEEN
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Eerste graad beschrijving Lijm",
                            ESchoolGrade = ESchoolGrade.EERSTE
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Tweede graad beschrijving Lijm",
                            ESchoolGrade = ESchoolGrade.TWEEDE
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Derde graad beschrijving Lijm",
                            ESchoolGrade = ESchoolGrade.DERDE
                        }
                    }
                };
                ProductTemplate pt3 = new ProductTemplate
                {
                    ProductName  = "Plakband",
                    Description  = "Dit is Plakband",
                    AddedByGO    = true,
                    ProductImage = "https://www.manutan.be/img/S/GRP/ST/AIG2328457.jpg",
                    Score        = 5,
                    HasMultipleDisplayVariations = true,
                    CategoryTemplateId           = ct1.CategoryTemplateId,
                    SchoolId = schoolGO.SchoolId,
                    ProductVariationTemplates = new List <ProductVariationTemplate>
                    {
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Algemene beschrijving Plakband",
                            ESchoolGrade = ESchoolGrade.ALGEMEEN
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Eerste graad beschrijving Plakband",
                            ESchoolGrade = ESchoolGrade.EERSTE
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Tweede graad beschrijving Plakband",
                            ESchoolGrade = ESchoolGrade.TWEEDE
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Derde graad beschrijving Plakband",
                            ESchoolGrade = ESchoolGrade.DERDE
                        }
                    }
                };

                ProductTemplate pt4 = new ProductTemplate
                {
                    ProductName  = "Hout",
                    Description  = "Dit is hout",
                    AddedByGO    = true,
                    ProductImage = "https://cdn.webshopapp.com/shops/34832/files/96705407/800x600x1/van-gelder-hout-schuttingplanken.jpg",
                    Score        = 8,
                    HasMultipleDisplayVariations = true,
                    CategoryTemplateId           = ct1.CategoryTemplateId,
                    SchoolId = schoolGO.SchoolId,
                    ProductVariationTemplates = new List <ProductVariationTemplate>
                    {
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Algemene beschrijving hout",
                            ESchoolGrade = ESchoolGrade.ALGEMEEN
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Eerste graad beschrijving Hout",
                            ESchoolGrade = ESchoolGrade.EERSTE
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Tweede graad beschrijving Hout",
                            ESchoolGrade = ESchoolGrade.TWEEDE
                        },
                        new ProductVariationTemplate
                        {
                            ProductDescr = "Derde graad beschrijving Hout",
                            ESchoolGrade = ESchoolGrade.DERDE
                        }
                    }
                };

                schoolGO.AddProductTemplate(pt1);
                schoolGO.AddProductTemplate(pt2);
                schoolGO.AddProductTemplate(pt3);
                schoolGO.AddProductTemplate(pt4);
                _dbContext.SaveChanges();
                #endregion

                #region ProjectTemplate

                ProjectTemplate projectTemplate = new ProjectTemplate
                {
                    AddedByGO = true,


                    ProjectDescr        = "Dit is een project voor energie",
                    ProjectImage        = "image",
                    ProjectName         = "Energie kennismaking",
                    SchoolId            = schoolGO.SchoolId,
                    Budget              = 20,
                    MaxScore            = 25,
                    ApplicationDomainId = energie.ApplicationDomainId
                };

                projectTemplate.AddProductTemplate(pt2);
                projectTemplate.AddProductTemplate(pt3);
                projectTemplate.AddProductTemplate(pt4);

                schoolGO.AddProjectTemplate(projectTemplate);

                _dbContext.SaveChanges();
                #endregion



                Category cat1 = new Category
                {
                    CategoryName  = "Bouwmaterialen",
                    CategoryDescr = "Zaken waarmee je kan bouwen"
                };

                Category cat2 = new Category
                {
                    CategoryName  = "Diverse",
                    CategoryDescr = "Andere gevallen"
                };

                Product pr1 = new Product
                {
                    Category     = cat1,
                    ProductName  = "Hout",
                    Description  = "Algemene beschrijving van hout",
                    Price        = 5,
                    Score        = 8,
                    ProductImage = "https://d16m3dafbknje9.cloudfront.net/imagescaler/9048544313374-500-500.jpg"
                };

                Product pr2 = new Product
                {
                    Category     = cat1,
                    ProductName  = "Papier",
                    Description  = "Algemene beschrijving van papier",
                    Price        = 3,
                    Score        = 7,
                    ProductImage = "http://tmib.com/wp-content/uploads/2014/08/stack-of-paper.jpg"
                };

                Product pr3 = new Product
                {
                    Category     = cat1,
                    ProductName  = "Plastiek",
                    Description  = "Algemene beschrijving van plastiek",
                    Price        = 10,
                    Score        = 2,
                    ProductImage = "https://img.etimg.com/thumb/msid-70477420,width-640,resizemode-4,imgsize-251889/the-most-recycled-plastic.jpg"
                };

                Product pr4 = new Product
                {
                    Category     = cat2,
                    ProductName  = "Plakband",
                    Description  = "Algemene beschrijving van plakband",
                    Price        = 10,
                    Score        = 6,
                    ProductImage = "https://discountoffice.nl/productImages/8/large/Q800250-3.jpg"
                };

                Group groep1 = new Group
                {
                    GroupId   = 1,
                    GroupName = "Groep 1",
                    GroupCode = "abcde"
                };

                Group groep2 = new Group
                {
                    GroupId   = 2,
                    GroupName = "Groep 2",
                    GroupCode = "12345"
                };

                Group groep3 = new Group
                {
                    GroupId   = 3,
                    GroupName = "Groep 3",
                    GroupCode = "azert"
                };


                groep2.InitOrder();
                groep3.InitOrder();

                //Projecten toevoegen

                //Project dat gestart is met 1 groep en 1 product
                Project project1 = new Project
                {
                    ProjectBudget       = 200,
                    ProjectDescr        = "Dit is een project over energie waar je iets leert over hechtingen, licht en schaduw via Reus en Dwerg.",
                    ProjectImage        = "image",
                    ProjectName         = "Ontdekdozen (hechtingen + licht/schaduw)",
                    ApplicationDomainId = energie.ApplicationDomainId,
                    ESchoolGrade        = ESchoolGrade.ALGEMEEN,
                };



                project1.AddProduct(pr1);
                project1.AddGroup(groep1);
                project1.AddGroup(groep3);
                cr.AddProject(project1);

                _dbContext.SaveChanges();


                #region Add evaluations for group 1 and 3



                #endregion



                _dbContext.SaveChanges();

                //Project dat gestart is met 1 groep en 3 producten
                Project project2 = new Project
                {
                    ProjectBudget       = 100,
                    ProjectDescr        = "Dit is een project over informatie en communicatie waarbij je leert seinen en blazen.",
                    ProjectImage        = "image",
                    ProjectName         = "Ontdekdozen (leren blazen + seinen)",
                    ApplicationDomainId = informatie.ApplicationDomainId,
                    ESchoolGrade        = ESchoolGrade.ALGEMEEN,
                };

                project2.AddProduct(pr1);
                project2.AddProduct(pr2);
                project2.AddProduct(pr3);
                project2.AddProduct(pr4);
                project2.AddGroup(groep2);
                cr.AddProject(project2);
                _dbContext.SaveChanges();

                //Project dat gestart is met geen groepen en geen producten
                Project project3 = new Project
                {
                    ProjectBudget       = 300,
                    ProjectDescr        = "Dit is een project over constructie waarbij je een muurtje maakt via het verhaal van de 3 biggetjes",
                    ProjectImage        = "image",
                    ProjectName         = "Ontdekdozen (bouwen)",
                    ApplicationDomainId = constructie.ApplicationDomainId,
                    ESchoolGrade        = ESchoolGrade.ALGEMEEN,
                };

                cr.AddProject(project3);
                _dbContext.SaveChanges();

                //Project dat gesloten is met geen groepen en geen producten
                Project project4 = new Project
                {
                    ProjectBudget       = 300,
                    ProjectDescr        = "Dit is een project over transport waarbij je een beetje maakt.",
                    ProjectImage        = "image",
                    ProjectName         = "Ontdekdozen (drijven/zinken)",
                    ApplicationDomainId = transport.ApplicationDomainId,
                    ESchoolGrade        = ESchoolGrade.EERSTE,
                    Closed = true,
                };

                cr.AddProject(project4);
                _dbContext.SaveChanges();
                groep1.Order = new Order
                {
                    OrderItems = new List <OrderItem>
                    {
                        new OrderItem
                        {
                            ProductId = pr1.ProductId,
                            Amount    = 2
                        }
                    }
                };



                _dbContext.SaveChanges();


                groep1.AddPupil(
                    new Pupil
                {
                    FirstName = "Daan",
                    Surname   = "Dedecker",
                    SchoolId  = schoolGO.SchoolId
                });

                groep1.AddPupil(
                    new Pupil
                {
                    FirstName = "Rambo",
                    Surname   = "Jansens",
                    SchoolId  = schoolGO.SchoolId
                });

                groep1.AddPupil(
                    new Pupil
                {
                    FirstName = "Piet",
                    Surname   = "Petter",
                    SchoolId  = schoolGO.SchoolId
                });



                _dbContext.SaveChanges();


                Project projectCr2 = new Project
                {
                    ProjectBudget       = 200,
                    ProjectDescr        = "Een project van klas 2",
                    ProjectImage        = "image",
                    ProjectName         = "Ontdekdozen ",
                    ApplicationDomainId = energie.ApplicationDomainId,
                    ESchoolGrade        = ESchoolGrade.ALGEMEEN,
                };
                cr2.AddProject(projectCr2);


                _dbContext.SaveChanges();
            }
        }
コード例 #22
0
        bool CreateProject()
        {
            if (templateView.CurrentlySelected != null)
            {
                PropertyService.Set("Dialogs.NewProjectDialog.LastSelectedCategory", ((ProjectTemplate)templateView.CurrentlySelected).Category);
                string template;
                // keep the old format if the language is not specified
                if (String.IsNullOrEmpty(templateView.CurrentlySelected.LanguageName))
                {
                    template = templateView.CurrentlySelected.Id;
                }
                else                     // use the newer format with language before id
                {
                    template = templateView.CurrentlySelected.LanguageName + "/" + templateView.CurrentlySelected.Id;
                }
                recentTemplates.Remove(template);
                recentTemplates.Insert(0, template);
                if (recentTemplates.Count > 15)
                {
                    recentTemplates.RemoveAt(recentTemplates.Count - 1);
                }
                string strRecent = string.Join(",", recentTemplates.ToArray());
                PropertyService.Set("Dialogs.NewProjectDialog.RecentTemplates", strRecent);
                PropertyService.SaveProperties();
                //PropertyService.Set("Dialogs.NewProjectDialog.LargeImages", ((RadioButton)ControlDictionary["largeIconsRadioButton"]).Checked);
            }

            string solution = txt_subdirectory.Text;
            string name     = txt_name.Text;
            string location = ProjectLocation;

            if (solution.Equals(""))
            {
                solution = name;                                 //This was empty when adding after first combine
            }
            if (
                (CreateSolutionDirectory &&
                 !FileService.IsValidPath(solution)) ||
                !FileService.IsValidFileName(name) ||
                name.IndexOf(' ') >= 0 ||
                !FileService.IsValidPath(location))
            {
                MessageService.ShowError(GettextCatalog.GetString("Illegal project name.\nOnly use letters, digits, '.' or '_'."));
                return(false);
            }

            if (parentFolder != null && parentFolder.ParentSolution.FindProjectByName(name) != null)
            {
                MessageService.ShowError(GettextCatalog.GetString("A Project with that name is already in your Project Space"));
                return(false);
            }

            PropertyService.Set(
                "MonoDevelop.Core.Gui.Dialogs.NewProjectDialog.AutoCreateProjectSubdir",
                CreateSolutionDirectory);

            if (templateView.CurrentlySelected == null || name.Length == 0)
            {
                return(false);
            }

            ProjectTemplate item = (ProjectTemplate)templateView.CurrentlySelected;

            try {
                if (Directory.Exists(ProjectLocation))
                {
                    var question = GettextCatalog.GetString("Directory {0} already exists.\nDo you want to continue creating the project?", ProjectLocation);
                    var btn      = MessageService.AskQuestion(question, AlertButton.No, AlertButton.Yes);
                    if (btn != AlertButton.Yes)
                    {
                        return(false);
                    }
                }

                Directory.CreateDirectory(location);
            } catch (IOException) {
                MessageService.ShowError(GettextCatalog.GetString("Could not create directory {0}. File already exists.", location));
                return(false);
            } catch (UnauthorizedAccessException) {
                MessageService.ShowError(GettextCatalog.GetString("You do not have permission to create to {0}", location));
                return(false);
            }

            if (newItem != null)
            {
                newItem.Dispose();
                newItem = null;
            }

            try {
                ProjectCreateInformation cinfo = CreateProjectCreateInformation();
                if (newSolution)
                {
                    newItem = item.CreateWorkspaceItem(cinfo);
                }
                else
                {
                    newItem = item.CreateProject(parentFolder, cinfo);
                }
                if (newItem == null)
                {
                    return(false);
                }
            } catch (UserException ex) {
                MessageService.ShowError(ex.Message, ex.Details);
                return(false);
            } catch (Exception ex) {
                MessageService.ShowException(ex, GettextCatalog.GetString("The project could not be created"));
                return(false);
            }
            selectedItem = item;
            return(true);
        }
コード例 #23
0
 public ComponentTemplateConverter(ProjectTemplate projectTemplate, string repositoryLocation, RepositoryReference repositoryReference = null)
 {
     this.projectTemplate     = projectTemplate ?? throw new ArgumentNullException(nameof(projectTemplate));
     this.repositoryLocation  = repositoryLocation ?? throw new ArgumentNullException(nameof(repositoryLocation));
     this.repositoryReference = repositoryReference ?? projectTemplate.Repository;
 }
コード例 #24
0
        bool CreateProject()
        {
            if (templateView.CurrentlySelected != null)
            {
                PropertyService.Set("Dialogs.NewProjectDialog.LastSelectedCategory", ((ProjectTemplate)templateView.CurrentlySelected).Category);
                recentIds.Remove(templateView.CurrentlySelected.Id);
                recentIds.Insert(0, templateView.CurrentlySelected.Id);
                if (recentIds.Count > 15)
                {
                    recentIds.RemoveAt(recentIds.Count - 1);
                }
                string strRecent = string.Join(",", recentIds.ToArray());
                PropertyService.Set("Dialogs.NewProjectDialog.RecentTemplates", strRecent);
                PropertyService.SaveProperties();
                //PropertyService.Set("Dialogs.NewProjectDialog.LargeImages", ((RadioButton)ControlDictionary["largeIconsRadioButton"]).Checked);
            }

            string solution = txt_subdirectory.Text;
            string name     = txt_name.Text;
            string location = ProjectLocation;

            if (solution.Equals(""))
            {
                solution = name;                                 //This was empty when adding after first combine
            }
            if (
                !FileService.IsValidPath(solution) ||
                !FileService.IsValidFileName(name) ||
                name.IndexOf(' ') >= 0 ||
                !FileService.IsValidPath(location))
            {
                MessageService.ShowError(GettextCatalog.GetString("Illegal project name.\nOnly use letters, digits, '.' or '_'."));
                return(false);
            }

            if (parentFolder != null && parentFolder.ParentSolution.FindProjectByName(name) != null)
            {
                MessageService.ShowError(GettextCatalog.GetString("A Project with that name is already in your Project Space"));
                return(false);
            }

            PropertyService.Set(
                "MonoDevelop.Core.Gui.Dialogs.NewProjectDialog.AutoCreateProjectSubdir",
                CreateSolutionDirectory);

            if (templateView.CurrentlySelected == null || name.Length == 0)
            {
                return(false);
            }

            ProjectTemplate item = (ProjectTemplate)templateView.CurrentlySelected;

            try {
                System.IO.Directory.CreateDirectory(location);
            } catch (IOException) {
                MessageService.ShowError(GettextCatalog.GetString("Could not create directory {0}. File already exists.", location));
                return(false);
            } catch (UnauthorizedAccessException) {
                MessageService.ShowError(GettextCatalog.GetString("You do not have permission to create to {0}", location));
                return(false);
            }

            ProjectCreateInformation cinfo = CreateProjectCreateInformation();

            try {
                if (newSolution)
                {
                    newItem = item.CreateWorkspaceItem(cinfo);
                }
                else
                {
                    newItem = item.CreateProject(parentFolder, cinfo);
                }
            } catch (Exception ex) {
                MessageService.ShowException(ex, GettextCatalog.GetString("The project could not be created"));
                return(false);
            }
            selectedItem = item;
            return(true);
        }
コード例 #25
0
ファイル: Program.cs プロジェクト: tiomke/paradox
        private static void GenerateUnitTestProject(string outputDirectory, string templateFile, string name)
        {
            var projectTemplate = ProjectTemplate.Load(templateFile);

            // Force reference to Paradox.Assets (to have acess to SolutionPlatform)
            projectTemplate.Assemblies.Add(typeof(GraphicsProfile).Assembly.FullName);
            projectTemplate.Assemblies.Add(typeof(ParadoxConfig).Assembly.FullName);

            var options = new Dictionary <string, object>();

            var session = new PackageSession();
            var result  = new LoggerResult();

            var templateGeneratorParameters = new TemplateGeneratorParameters();

            templateGeneratorParameters.OutputDirectory = outputDirectory;
            templateGeneratorParameters.Session         = session;
            templateGeneratorParameters.Name            = name;
            templateGeneratorParameters.Logger          = result;
            templateGeneratorParameters.Description     = new TemplateDescription();

            PackageUnitTestGenerator.Default.Generate(templateGeneratorParameters);
            if (result.HasErrors)
            {
                Console.WriteLine("Error generating package: {0}", result.ToText());
                return;
            }

            var package = templateGeneratorParameters.Package;

            var previousCurrent = session.CurrentPackage;

            session.CurrentPackage = package;

            // Compute Paradox Sdk relative path
            // We are supposed to be in standard output binary folder, so Paradox root should be at ..\..
            var paradoxPath         = UDirectory.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), new UDirectory(@"..\.."));
            var paradoxRelativePath = new UDirectory(paradoxPath)
                                      .MakeRelative(outputDirectory)
                                      .ToString()
                                      .Replace('/', '\\');

            paradoxRelativePath = paradoxRelativePath.TrimEnd('\\');

            options["Namespace"]             = name;
            options["Package"]               = package;
            options["Platforms"]             = new List <SolutionPlatform>(AssetRegistry.SupportedPlatforms);
            options["ParadoxSdkRelativeDir"] = paradoxRelativePath;

            // Generate project template
            var projectGuid = Guid.NewGuid();

            result = projectTemplate.Generate(outputDirectory, name, projectGuid, options);
            if (result.HasErrors)
            {
                Console.WriteLine("Error generating solution: {0}", result.ToText());
                return;
            }

            var sharedProfile = package.Profiles.FindSharedProfile();

            // Setup the assets folder
            Directory.CreateDirectory(UPath.Combine(outputDirectory, (UDirectory)"Assets/Shared"));

            // Add Windows test as Shared library
            var projectWindowsRef = new ProjectReference();

            projectWindowsRef.Id       = projectGuid;
            projectWindowsRef.Location = UPath.Combine(outputDirectory, (UFile)(name + ".Windows.csproj"));
            projectWindowsRef.Type     = SiliconStudio.Assets.ProjectType.Library;
            sharedProfile.ProjectReferences.Add(projectWindowsRef);

            // Generate executable projects for each platform
            foreach (var platform in AssetRegistry.SupportedPlatforms)
            {
                var platformProfile = new PackageProfile(platform.Name)
                {
                    Platform = platform.Type
                };
                platformProfile.AssetFolders.Add(new AssetFolder("Assets/" + platform.Name));

                // Log progress
                var projectName = name + "." + platform.Type;

                // Create project reference
                var projectPlatformRef = new ProjectReference();
                projectPlatformRef.Id       = projectGuid;
                projectPlatformRef.Location = UPath.Combine(outputDirectory, (UFile)(projectName + ".csproj"));
                projectPlatformRef.Type     = SiliconStudio.Assets.ProjectType.Executable;

                platformProfile.ProjectReferences.Add(projectPlatformRef);

                // Add build configuration per platform
                platform.Properties.CopyTo(platformProfile.Properties, true);

                package.Profiles.Add(platformProfile);
            }

            session.CurrentPackage = previousCurrent;

            result = session.Save();
            if (result.HasErrors)
            {
                Console.WriteLine("Error saving package: {0}", result.ToText());
                return;
            }
        }
コード例 #26
0
 public TemplateItem(ProjectTemplate template)
 {
     name          = StringParserService.Parse(template.Name);
     this.template = template;
 }
コード例 #27
0
 public ProjectInfo(string name, ProjectTemplate template)
 {
     this.Name     = name;
     this.Template = template;
 }
コード例 #28
0
ファイル: Current.cs プロジェクト: Korduene/Korduene
        public void CreateSolution(string name, string directory, ProjectTemplate template)
        {
            var slnDir = Path.Combine(directory, name);

            Directory.CreateDirectory(slnDir);

            var sln = new Microsoft.DotNet.Cli.Sln.Internal.SlnFile
            {
                FullPath                   = Path.Combine(slnDir, $"{name}.sln"),
                ProductDescription         = "Visual Studio Version 16",
                FormatVersion              = "12.00",
                VisualStudioVersion        = "16",
                MinimumVisualStudioVersion = "10"
            };

            //create project dir
            var projDir = Path.Combine(slnDir, name);

            template.CreateFiles(projDir);

            var fullPath = Path.Combine(directory, name, template.ChosenName + Path.GetExtension(template.MainFile));

            var proj = new Microsoft.DotNet.Cli.Sln.Internal.SlnProject()
            {
                Id       = template.Id,
                FilePath = Path.GetRelativePath(directory, fullPath),
                Name     = name,
                TypeGuid = template.ProjectTypeGuid
            };

            sln.Projects.Add(proj);

            var projConfig = new Microsoft.DotNet.Cli.Sln.Internal.SlnPropertySet(proj.Id);

            projConfig.SetValue("Debug|Any CPU.ActiveCfg", "Debug|Any CPU");
            projConfig.SetValue("Debug|Any CPU.Build.0", "Debug|Any CPU");
            projConfig.SetValue("Release|Any CPU.ActiveCfg", "Release|Any CPU");
            projConfig.SetValue("Release|Any CPU.Build.0", "Release|Any CPU");

            sln.SolutionConfigurationsSection.SetValue("Debug|Any CPU", "Debug|Any CPU");
            sln.SolutionConfigurationsSection.SetValue("Release|Any CPU", "Release|Any CPU");

            sln.ProjectConfigurationsSection.Add(projConfig);
            var slnProperties = new Microsoft.DotNet.Cli.Sln.Internal.SlnSection()
            {
                Id = "SolutionProperties"
            };

            slnProperties.Properties.SetValue("HideSolutionNode", "FALSE");
            sln.Sections.Add(slnProperties);

            var extGlobals = new Microsoft.DotNet.Cli.Sln.Internal.SlnSection()
            {
                Id          = "ExtensibilityGlobals",
                SectionType = Microsoft.DotNet.Cli.Sln.Internal.SlnSectionType.PostProcess
            };

            extGlobals.Properties.SetValue("SolutionGuid", $"{{{Guid.NewGuid().ToString()}}}");
            sln.Sections.Add(extGlobals);

            sln.Write();

            OpenSolution(sln.FullPath);
        }
コード例 #29
0
        public DummyApplicationDbContext()
        {
            Product testP1 = new Product
            {
                ProductId   = 1,
                ProductName = "Karton",
                Description = "Karton beschrijving",
                Price       = 5
            };

            Product testP2 = new Product
            {
                ProductId   = 2,
                ProductName = "Plastiek",
                Description = "plastiek beschrijving",
                Price       = 20
            };

            Product testP3 = new Product
            {
                ProductId   = 3,
                ProductName = "Lijm",
                Description = "Lijm beschrijving",
                Price       = 8.5
            };

            Product testP4 = new Product
            {
                ProductId   = 4,
                ProductName = "Plakband",
                Description = "Plakband beschrijving",
                Price       = 15
            };

            OrderItem testOrderItem1 = new OrderItem
            {
                OrderItemId = 1,
                Product     = testP1,
                Amount      = 2,
                ProductId   = 1
            };

            OrderItem testOrderItem2 = new OrderItem
            {
                OrderItemId = 2,
                Product     = testP2,
                Amount      = 1,
                ProductId   = 2
            };

            OrderItem testOrderItem3 = new OrderItem
            {
                OrderItemId = 3,
                Product     = testP3,
                Amount      = 3,
                ProductId   = 3
            };

            testOrderItem = new OrderItem
            {
                OrderItemId = 4,
                Product     = testP4,
                Amount      = 5,
                ProductId   = 4
            };

            testOrder = new Order
            {
                OrderId    = 1,
                Approved   = false,
                Submitted  = false,
                OrderItems = new List <OrderItem>
                {
                    testOrderItem1,
                    testOrderItem2,
                    testOrderItem3
                }
            };
            ApplicationDomain applicationDomainTest = new ApplicationDomain
            {
                ApplicationDomainId    = 1,
                ApplicationDomainName  = "naam",
                ApplicationDomainDescr = "niet veel speciaals"
            };

            testGroup = new Group
            {
                GroupId   = 1,
                GroupName = "groepsnaam",
                Order     = testOrder
            };

            testProject = new Project
            {
                ProjectName         = "testproject",
                ProjectDescr        = "ceci est une beschrijving",
                ProjectImage        = "url",
                ProjectBudget       = 20,
                ESchoolGrade        = ESchoolGrade.ALGEMEEN,
                Closed              = false,
                ApplicationDomainId = 1
            };

            projectTemplate1 = new ProjectTemplate
            {
                ProjectName                     = "DitIsEenTest",
                ProjectDescr                    = "Dit is een test voor rojecttemplate",
                ProjectImage                    = "ceci n'est pas une url",
                AddedByGO                       = true,
                ApplicationDomainId             = 1,
                ApplicationDomain               = applicationDomainTest,
                ProductTemplateProjectTemplates = new List <ProductTemplateProjectTemplate>()
            };
            projectTemplate2 = new ProjectTemplate
            {
                ProjectName         = "DitIsEenAndereTest",
                ProjectDescr        = "Dit is 2e een test voor projecttemplate",
                ProjectImage        = "ceci n'est aussie pas une url",
                AddedByGO           = false,
                ApplicationDomainId = 2
            };
            producttemplate1 = new ProductTemplate
            {
                ProductName  = "DitIsEenProductTemplateTest",
                Description  = "dit is een beschrijving voor een producttemplate",
                ProductImage = "dit is ook geen url",
                AddedByGO    = true
            };
            producttemplate2 = new ProductTemplate
            {
                ProductName  = "DitIsEentweedeProductTemplateTest",
                Description  = "dit is een beschrijving voor een andere producttemplate",
                ProductImage = "dit is ook geen url, zot eh",
                AddedByGO    = false
            };
        }
コード例 #30
0
        public async Task UpdatePackageForPC_PackageNamespace_WithMultipleFeedsWithIdenticalPackages_UpdatesCorrectPackage(ProjectTemplate projectTemplate)
        {
            // Arrange
            EnsureVisualStudioHost();

            using var simpleTestPathContext = new SimpleTestPathContext();
            string solutionDirectory = simpleTestPathContext.SolutionRoot;
            var    packageName       = "Contoso.A";
            var    packageVersion1   = "1.0.0";
            var    packageVersion2   = "2.0.0";

            var opensourceRepositoryPath = Path.Combine(solutionDirectory, "OpensourceRepository");

            Directory.CreateDirectory(opensourceRepositoryPath);

            await CommonUtility.CreateNetCorePackageInSourceAsync(opensourceRepositoryPath, packageName, packageVersion1, "Thisisfromopensourcerepo1.txt");

            await CommonUtility.CreateNetCorePackageInSourceAsync(opensourceRepositoryPath, packageName, packageVersion2, "Thisisfromopensourcerepo2.txt");

            var privateRepositoryPath = Path.Combine(solutionDirectory, "PrivateRepository");

            Directory.CreateDirectory(privateRepositoryPath);

            await CommonUtility.CreateNetCorePackageInSourceAsync(privateRepositoryPath, packageName, packageVersion1, "Thisisfromprivaterepo1.txt");

            await CommonUtility.CreateNetCorePackageInSourceAsync(privateRepositoryPath, packageName, packageVersion2, "Thisisfromprivaterepo2.txt");

            //Create nuget.config with Package namespace filtering rules.
            CommonUtility.CreateConfigurationFile(Path.Combine(solutionDirectory, "NuGet.config"), $@"<?xml version=""1.0"" encoding=""utf-8""?>
<configuration>
    <packageSources>
    <!--To inherit the global NuGet package sources remove the <clear/> line below -->
    <clear />
    <add key=""ExternalRepository"" value=""{opensourceRepositoryPath}"" />
    <add key=""PrivateRepository"" value=""{privateRepositoryPath}"" />
    </packageSources>
    <packageNamespaces>
        <packageSource key=""externalRepository"">
            <namespace id=""External.*"" />
            <namespace id=""Others.*"" />
        </packageSource>
        <packageSource key=""PrivateRepository"">
            <namespace id=""Contoso.*"" />             
            <namespace id=""Test.*"" />
        </packageSource>
    </packageNamespaces>
//</configuration>");

            using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger, noAutoRestore: false, addNetStandardFeeds: false, simpleTestPathContext: simpleTestPathContext))
            {
                var nugetConsole = GetConsole(testContext.Project);

                // Act
                nugetConsole.InstallPackageFromPMC(packageName, packageVersion1);
                nugetConsole.UpdatePackageFromPMC(packageName, packageVersion2);

                // Assert
                CommonUtility.AssertPackageInPackagesConfig(VisualStudio, testContext.Project, packageName, packageVersion2, XunitLogger);

                var packagesDirectory = Path.Combine(solutionDirectory, "packages");
                var uniqueContentFile = Path.Combine(packagesDirectory, packageName + '.' + packageVersion2, "lib", "net5.0", "Thisisfromprivaterepo2.txt");
                // Make sure name squatting package not restored from  opensource repository.
                Assert.True(File.Exists(uniqueContentFile));
            }
        }
コード例 #31
0
 // TODO: Adjust language name based on whether we are using a web template
 private string GetProjectTemplatePath(ProjectTemplate projectTemplate, ProjectLanguage projectLanguage)
 => IntegrationHelper.RetryRpcCall(() => _dteSolution.GetProjectTemplate(_projectTemplates[projectTemplate], ProjectLanguages[projectLanguage]));
コード例 #32
0
ファイル: Program.cs プロジェクト: Aggror/Stride
        private static void GenerateUnitTestProject(string outputDirectory, string templateFile, string name, string projectNamespace)
        {
            var projectTemplate = ProjectTemplate.Load(templateFile);

            // Force reference to Stride.Assets (to have acess to SolutionPlatform)
            projectTemplate.Assemblies.Add(typeof(GraphicsProfile).Assembly.FullName);
            projectTemplate.Assemblies.Add(typeof(StrideConfig).Assembly.FullName);

            var options = new Dictionary <string, object>();

            // When generating over an existing set of files, retrieve the existing IDs
            // for better incrementality
            Guid projectGuid, assetId;

            GetExistingGuid(outputDirectory, name + ".Windows.csproj", out projectGuid);
            GetExistingAssetId(outputDirectory, name + ".sdpkg", out assetId);

            var session = new PackageSession();
            var result  = new LoggerResult();

            var templateGeneratorParameters = new SessionTemplateGeneratorParameters();

            templateGeneratorParameters.OutputDirectory = outputDirectory;
            templateGeneratorParameters.Session         = session;
            templateGeneratorParameters.Name            = name;
            templateGeneratorParameters.Logger          = result;
            templateGeneratorParameters.Description     = new TemplateDescription();
            templateGeneratorParameters.Id        = assetId;
            templateGeneratorParameters.Namespace = projectNamespace;

            if (!PackageUnitTestGenerator.Default.PrepareForRun(templateGeneratorParameters).Result)
            {
                Console.WriteLine(@"Error generating package: PackageUnitTestGenerator.PrepareForRun returned false");
                return;
            }
            if (!PackageUnitTestGenerator.Default.Run(templateGeneratorParameters))
            {
                Console.WriteLine(@"Error generating package: PackageUnitTestGenerator.Run returned false");
                return;
            }
            if (result.HasErrors)
            {
                Console.WriteLine($"Error generating package: {result.ToText()}");
                return;
            }

            var project = session.Projects.OfType <SolutionProject>().Single();

            var previousCurrent = session.CurrentProject;

            session.CurrentProject = project;

            // Compute Stride Sdk relative path
            // We are supposed to be in standard output binary folder, so Stride root should be at ..\..
            var stridePath         = UPath.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), new UDirectory(@"..\.."));
            var strideRelativePath = new UDirectory(stridePath)
                                     .MakeRelative(outputDirectory)
                                     .ToString()
                                     .Replace('/', '\\');

            strideRelativePath = strideRelativePath.TrimEnd('\\');

            options["Namespace"]            = projectNamespace ?? name;
            options["Package"]              = project.Package;
            options["Platforms"]            = new List <SolutionPlatform>(AssetRegistry.SupportedPlatforms);
            options["StrideSdkRelativeDir"] = strideRelativePath;

            // Generate project template
            result = projectTemplate.Generate(outputDirectory, name, projectGuid, options);
            if (result.HasErrors)
            {
                Console.WriteLine("Error generating solution: {0}", result.ToText());
                return;
            }

            // Setup the assets folder
            Directory.CreateDirectory(UPath.Combine(outputDirectory, (UDirectory)"Assets/Shared"));

            session.CurrentProject = previousCurrent;

            session.Save(result);
            if (result.HasErrors)
            {
                Console.WriteLine("Error saving package: {0}", result.ToText());
                return;
            }
        }
コード例 #33
0
        public async Task AuthorSignedPackage_WithExpiredCertificate_InstallFromPMCForPC_SucceedAsync(ProjectTemplate projectTemplate)
        {
            // Arrange
            EnsureVisualStudioHost();

            await _fixture.CreateSignedPackageWithExpiredCertificateAsync();

            var signedPackagePath = _fixture.ExpiredCertSignedTestPackagePath;
            var signedPackage     = _fixture.ExpiredCertSignedTestPackage;

            using (var testContext = new ApexTestContext(VisualStudio, projectTemplate, XunitLogger))
            {
                File.Copy(signedPackagePath, Path.Combine(testContext.PackageSource, signedPackage.PackageName));

                var nugetConsole = GetConsole(testContext.Project);

                nugetConsole.InstallPackageFromPMC(signedPackage.Id, signedPackage.Version);

                // TODO: Fix bug where no warnings are shwon when package is untrusted but still installed
                //nugetConsole.IsMessageFoundInPMC("expired certificate").Should().BeTrue("expired certificate warning");
                Utils.AssetPackageInPackagesConfig(VisualStudio, testContext.Project, signedPackage.Id, signedPackage.Version, XunitLogger);
            }
        }