ServiceClientGenerator.ProjectFileCreator.ExecuteCore C# (CSharp) Method

ExecuteCore() public method

public ExecuteCore ( string coreFilesRoot, IEnumerable projectFileConfigurations ) : void
coreFilesRoot string
projectFileConfigurations IEnumerable
return void
        public void ExecuteCore(string coreFilesRoot, IEnumerable<ProjectFileConfiguration> projectFileConfigurations)
        {
            CreatedProjectFiles = new Dictionary<string, ProjectConfigurationData>();

            foreach (var projectFileConfiguration in projectFileConfigurations)
            {
                var projectType = projectFileConfiguration.Name;

                var assemblyName = "AWSSDK.Core";
                var projectFilename = string.Concat(assemblyName, ".", projectType, ".csproj");
                bool newProject = false;
                string projectGuid;
                if (File.Exists(Path.Combine(coreFilesRoot, projectFilename)))
                {
                    Console.WriteLine("...updating existing project file {0}", projectFilename);
                    var projectPath = Path.Combine(coreFilesRoot, projectFilename);
                    projectGuid = Utils.GetProjectGuid(projectPath);
                }
                else
                {
                    newProject = true;
                    projectGuid = Utils.NewProjectGuid;
                    Console.WriteLine("...creating project file {0}", projectFilename);
                }


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

                templateSession["Name"] = projectFileConfiguration.Name;
                templateSession["ProjectGuid"] = projectGuid;
                templateSession["RootNamespace"] = "Amazon";
                templateSession["AssemblyName"] = assemblyName;
                templateSession["SourceDirectories"] = GetCoreProjectSourceFolders(projectFileConfiguration, coreFilesRoot);
                templateSession["IndividualFileIncludes"] = new List<string>
                {
                    "endpoints.json",
                };
                templateSession["KeyFilePath"] = @"..\..\awssdk.dll.snk";
                templateSession["SupressWarnings"] = "419,1570,1591";
                templateSession["NugetPackagesLocation"] = @"..\..\packages\";
                templateSession["TargetFrameworkVersion"] = projectFileConfiguration.TargetFrameworkVersion;
                templateSession["DefineConstants"] = projectFileConfiguration.CompilationConstants;
                templateSession["BinSubfolder"] = projectFileConfiguration.BinSubFolder;

                var projectConfigurationData = new ProjectConfigurationData { ProjectGuid = projectGuid };
                var projectName = Path.GetFileNameWithoutExtension(projectFilename);

                if (newProject)
                    CreatedProjectFiles[projectName] = projectConfigurationData;

                var projectReferences = new List<ProjectReference>();
                templateSession["ProjectReferences"] = projectReferences.OrderBy(x => x.Name).ToList();

                templateSession["UnityPath"] = Options.UnityPath;

                GenerateProjectFile(projectFileConfiguration, projectConfigurationData, templateSession, coreFilesRoot, projectFilename);
            }
        }

Usage Example

Exemplo n.º 1
0
 public static void GenerateCoreProjects(GenerationManifest generationManifest,
     GeneratorOptions options)
 {
     Console.WriteLine("Updating Core project files.");
     string coreFilesRoot = Path.Combine(options.SdkRootFolder, "src", "core");
     var creator = new ProjectFileCreator();
     creator.ExecuteCore(coreFilesRoot, generationManifest.ProjectFileConfigurations);
     foreach (var newProjectKey in creator.CreatedProjectFiles.Keys)
     {
         NewlyCreatedProjectFiles.Add(newProjectKey, creator.CreatedProjectFiles[newProjectKey]);
     }
 }