public void Setup()
        {
            CreateEmptyXmlDocument(_mvcProjectFilePath);
            CreateEmptyXmlDocument(_classLibraryProjectFilePath);
            CreateEmptyXmlDocument(_webClassLibraryProjectFilePath);

            var targetFramework = new List <string> {
                "netcoreapp3.1"
            };
            var packages = new Dictionary <string, string>
            {
                { "MyFirstPackage", "1.0.0" },
                { "MySecondPackage", "2.0.0" }
            };
            var projectReferences = new List <string>
            {
                "TheMainProject",
                "TheDependency"
            };
            var metaRefs = new List <string>
            {
                @"C:\\RandomFile.dll"
            };

            _mvcProjectFileCreator = new ProjectFileCreator(_mvcProjectFilePath, targetFramework,
                                                            packages, projectReferences, ProjectType.Mvc, metaRefs);
            _classLibraryProjectFileCreator = new ProjectFileCreator(_classLibraryProjectFilePath, targetFramework,
                                                                     packages, projectReferences, ProjectType.ClassLibrary, metaRefs);
            _webClassLibraryProjectFileCreator = new ProjectFileCreator(_webClassLibraryProjectFilePath, targetFramework,
                                                                        packages, projectReferences, ProjectType.WebClassLibrary, metaRefs);
        }
Exemple #2
0
        private string GenerateProjectFileContents(ProjectResult projectResult,
                                                   ProjectConfiguration projectConfiguration, List <String> projectReferences, List <String> metaReferences)
        {
            var projectActions = projectResult.ProjectActions;
            var packages       = projectActions.PackageActions.Distinct()
                                 .ToDictionary(p => p.Name, p => p.Version);

            // Now we can finally create the ProjectFileCreator and use it
            var projectFileCreator = new ProjectFileCreator(FullPath, projectConfiguration.TargetVersions, packages,
                                                            projectReferences, ProjectType.WebForms, metaReferences);

            return(projectFileCreator.CreateContents());
        }
        public Func <string, ProjectType, List <string>, Dictionary <string, string>, List <string>, string> GetMigrateProjectFileAction(string empty)
        {
            Func <string, ProjectType, List <string>, Dictionary <string, string>, List <string>, string> func
                = (string projectDir, ProjectType projectType, List <string> targetVersion, Dictionary <string, string> packageReferences, List <string> projectReferences) =>
                {
                ProjectFileCreator projectFileCreator = new ProjectFileCreator(projectDir, targetVersion,
                                                                               packageReferences, projectReferences.ToList(), projectType);

                var result = projectFileCreator.Create();
                return(result ? "Project file created" : string.Empty);
                };

            return(func);
        }