private IList <ProjectFileCreator.ProjectReference> ServiceProjectReferences(string unitTestRoot, IEnumerable <ServiceConfiguration> serviceConfigurations, string projectType) { HashSet <string> guidSet = new HashSet <string>(); List <ProjectFileCreator.ProjectReference> references = new List <ProjectFileCreator.ProjectReference>(); foreach (var configuration in serviceConfigurations) { string projectName = string.Format("{0}.{1}", configuration.AssemblyTitle, projectType); string includePath = Path.Combine("..", "..", "src", "Services", configuration.ServiceFolderName, projectName + ".csproj"); string guid = Utils.GetProjectGuid(Path.Combine(unitTestRoot, includePath)); if (guidSet.Contains(guid)) { // ServiceConfiguration list contains two entries for DynamoDBv2 and DynamoDBStreams // which resolve to the same project. continue; } references.Add(new ProjectFileCreator.ProjectReference { Name = projectName, IncludePath = includePath, ProjectGuid = guid }); guidSet.Add(guid); } references.Sort(); return(references); }
public List <Project> GetListOfCodeAnalysisProjects() { List <Project> projects = new List <Project>(); var codeAnalysisProjectsRoot = Path.Combine(Options.SdkRootFolder, GeneratorDriver.CodeAnalysisFoldername); foreach (var projectFile in Directory.GetFiles(codeAnalysisProjectsRoot, projectTypeWildCard, SearchOption.AllDirectories).OrderBy(x => x)) { var fullPath = Path.GetFullPath(projectFile); var relativePath = fullPath.Substring(fullPath.IndexOf("code-analysis")); var projectNameInSolution = Path.GetFileNameWithoutExtension(projectFile); var project = new Project { Name = projectNameInSolution, ShortName = projectNameInSolution.Replace("AWSSDK.", "").Replace(".CodeAnalysis", ""), ProjectGuid = Utils.GetProjectGuid(projectFile), ProjectPath = relativePath }; projects.Add(project); } return(projects); }
private IList <ProjectFileCreator.ProjectReference> GetCommonReferences(string unitTestRoot, string projectType) { IList <ProjectFileCreator.ProjectReference> references = new List <ProjectFileCreator.ProjectReference>(); // // Core project reference // string coreProjectName = string.Format("AWSSDK.Core.{0}", projectType); string coreIncludePath = Path.Combine("..", "..", "src", "Core", coreProjectName + ".csproj"); string coreProjectPath = Path.Combine(unitTestRoot, coreIncludePath); references.Add(new ProjectFileCreator.ProjectReference { Name = coreProjectName, IncludePath = coreIncludePath, ProjectGuid = Utils.GetProjectGuid(coreProjectPath) }); // // CommonTest project reference // string commonTestProjectName = string.Format("AWSSDK.CommonTest.{0}", projectType); string commonTestIncludePath = Path.Combine("..", "Common", commonTestProjectName + ".csproj"); string commonTestPath = Path.Combine(unitTestRoot, commonTestIncludePath); references.Add(new ProjectFileCreator.ProjectReference { Name = commonTestProjectName, IncludePath = commonTestIncludePath, ProjectGuid = Utils.GetProjectGuid(commonTestPath) }); return(references); }
/// <summary> /// Scans the SDK source and test folder locations to detect existing projects that /// follow our naming convention, adding them to the set of all projects to be /// processed into the solution files. /// </summary> private void ScanForExistingProjects() { const string awssdkProjectNamePattern = "AWSSDK.*.*proj"; var foldersToProcess = new[] { Path.Combine(Options.SdkRootFolder, GeneratorDriver.SourceSubFoldername), Path.Combine(Options.SdkRootFolder, GeneratorDriver.TestsSubFoldername) }; foreach (var rootFolder in foldersToProcess) { foreach (var projectFile in Directory.GetFiles(rootFolder, awssdkProjectNamePattern, SearchOption.AllDirectories)) { var projectName = Path.GetFileNameWithoutExtension(projectFile); if (_allProjects.ContainsKey(projectName)) { continue; } var projectConfig = new ProjectFileCreator.ProjectConfigurationData { ProjectGuid = Utils.GetProjectGuid(projectFile), ConfigurationPlatforms = GetProjectPlatforms(projectName) }; _allProjects.Add(projectName, projectConfig); } } }
public void Execute(string unitTestRoot, IEnumerable <ServiceConfiguration> serviceConfigurations, bool useDllReference) { foreach (var configuration in _configurations) { string projectName = string.Format("AWSSDK.UnitTests.{0}.csproj", configuration.Name); string projectGuid = Utils.GetProjectGuid(Path.Combine(unitTestRoot, projectName)); IList <ProjectFileCreator.ProjectReference> commonReferences; IList <ProjectFileCreator.ProjectReference> serviceProjectReferences; IList <ProjectFileCreator.Reference> dllProjectReferences; if (useDllReference) { projectName = string.Format("Build.UnitTests.{0}.partial.csproj", configuration.Name); serviceProjectReferences = null; dllProjectReferences = ServiceDllReferences(unitTestRoot, serviceConfigurations, configuration.Name); } else { serviceProjectReferences = ServiceProjectReferences(unitTestRoot, serviceConfigurations, configuration.Name); dllProjectReferences = null; } commonReferences = GetCommonReferences(unitTestRoot, configuration.Name, useDllReference); var session = new Dictionary <string, object> { { "AssemblyName", string.Format("AWSSDK.UnitTests.{0}", configuration.Name) }, { "TargetFramework", configuration.TargetFrameworkVersion }, { "DefineConstants", "DEBUG;" + configuration.CompilationConstants }, { "Reference", configuration.FrameworkReferences }, { "CompileRemoveList", configuration.PlatformExcludeFolders }, { "EmbeddedResources", configuration.EmbeddedResources }, { "Services", configuration.VisualStudioServices }, { "ReferencePath", configuration.ReferencePath }, { "FrameworkPathOverride", configuration.FrameworkPathOverride }, { "FrameworkReferences", configuration.FrameworkReferences }, { "PackageReferenceList", configuration.PackageReferences }, { "NoWarn", configuration.NoWarn }, { "OutputPathOverride", configuration.OutputPathOverride }, { "SignBinaries", false }, }; if (useDllReference) { session.Add("ServiceDllReferences", dllProjectReferences); } if (serviceProjectReferences != null) { session.Add("ProjectReferenceList", commonReferences.Concat(serviceProjectReferences).ToList()); } else { session.Add("ProjectReferenceList", commonReferences); } GenerateProjectFile(session, unitTestRoot, projectName); } }
private void GenerateCoreCLRProjectFiles(string serviceFilesRoot, ServiceConfiguration serviceConfiguration, string assemblyName) { var projectFilename = string.Concat(assemblyName, ".CoreCLR.xproj"); string projectGuid; if (File.Exists(Path.Combine(serviceFilesRoot, projectFilename))) { Console.WriteLine("...updating existing project file {0}", projectFilename); var projectPath = Path.Combine(serviceFilesRoot, projectFilename); projectGuid = Utils.GetProjectGuid(projectPath); } else { projectGuid = Utils.NewProjectGuid; Console.WriteLine("...creating project file {0}", projectFilename); } { var templateSession = new Dictionary <string, object>(); templateSession["RootNamespace"] = serviceConfiguration.Namespace; templateSession["AssemblyName"] = assemblyName; templateSession["ProjectGuid"] = projectGuid; CoreCLRProjectFile projectFileTemplate = new CoreCLRProjectFile(); projectFileTemplate.Session = templateSession; var content = projectFileTemplate.TransformText(); GeneratorDriver.WriteFile(serviceFilesRoot, string.Empty, projectFilename, content); } { var templateSession = new Dictionary <string, object>(); var dependencies = new List <string>(); foreach (var dependency in serviceConfiguration.ServiceDependencies.Keys) { if (string.Equals(dependency, "Core", StringComparison.InvariantCultureIgnoreCase)) { continue; } dependencies.Add(dependency); } templateSession["ServiceDependencies"] = dependencies; templateSession["AssemblyName"] = assemblyName; var projectJsonTemplate = new CoreCLRProjectJson(); projectJsonTemplate.Session = templateSession; var content = projectJsonTemplate.TransformText(); GeneratorDriver.WriteFile(serviceFilesRoot, string.Empty, "project.json", content); } }
public void Execute(string unitTestRoot, IEnumerable <ServiceConfiguration> serviceConfigurations) { string net35TestProjectName = "AWSSDK.UnitTests.Net35.csproj"; var templateSession35 = new Dictionary <string, object> { { "ProjectGuid", Utils.GetProjectGuid(Path.Combine(unitTestRoot, net35TestProjectName)) }, { "RootNamespace", "AWSSDK_DotNet35.UnitTests" }, { "AssemblyName", "AWSSDK.UnitTests.Net35" }, { "DebugOutputPath", @"bin\Debug\net35" }, { "ReleaseOutputPath", @"bin\Release\net35" }, { "ReleaseDefineConstants", "TRACE;;BCL;BCL35;AWS_APM_API;LOCAL_FILE" }, { "DebugDefineConstants", "DEBUG;TRACE;;BCL;BCL35;AWS_APM_API;LOCAL_FILE" }, { "Reference", null }, { "CompileInclude", null }, { "CommonReferences", GetCommonReferences(unitTestRoot, "Net35") }, { "ServiceProjectReferences", ServiceProjectReferences(unitTestRoot, serviceConfigurations, "Net35") }, { "ServiceDllReferences", ServiceDllReferences(unitTestRoot, serviceConfigurations, "Net35") }, }; GenerateProjectFile(templateSession35, unitTestRoot, net35TestProjectName); string net45TestProjectName = "AWSSDK.UnitTests.Net45.csproj"; var templateSession45 = new Dictionary <string, object> { { "ProjectGuid", Utils.GetProjectGuid(Path.Combine(unitTestRoot, net45TestProjectName)) }, { "RootNamespace", "AWSSDK_DotNet45.UnitTests" }, { "AssemblyName", "AWSSDK.UnitTests.Net45" }, { "DebugOutputPath", @"bin\Debug\net45" }, { "DebugDefineConstants", "DEBUG;TRACE;;BCL;BCL45;ASYNC_AWAIT;AWS_APM_API;LOCAL_FILE" }, { "ReleaseOutputPath", @"bin\Release\net45" }, { "ReleaseDefineConstants", "TRACE;;BCL;BCL45;ASYNC_AWAIT;AWS_APM_API;LOCAL_FILE" }, { "Reference", new List <string> { "System.Net.Http" } }, { "CompileInclude", new List <string> { @"Custom\*\_bcl45\*.cs" } }, { "CommonReferences", GetCommonReferences(unitTestRoot, "Net45") }, { "ServiceProjectReferences", ServiceProjectReferences(unitTestRoot, serviceConfigurations, "Net45") }, { "ServiceDllReferences", ServiceDllReferences(unitTestRoot, serviceConfigurations, "Net45") }, }; GenerateProjectFile(templateSession45, unitTestRoot, net45TestProjectName); }
private void AddExtraTestProjects(ProjectFileConfiguration projectConfig, Dictionary <string, ProjectFileCreator.ProjectConfigurationData> solutionProjects, List <Project> testProjects) { foreach (var extraTestProject in projectConfig.ExtraTestProjects) { var projectPath = @"..\..\..\..\sdk\" + extraTestProject; var projectGuid = Utils.GetProjectGuid(projectPath); var testProject = ProjectFromFile(extraTestProject, projectGuid); var testProjectConfig = new ProjectFileCreator.ProjectConfigurationData { ProjectGuid = projectGuid, ConfigurationPlatforms = GetProjectPlatformsFromFile(projectPath).ToList() }; solutionProjects.Add(testProject.Name, testProjectConfig); testProjects.Add(testProject); } }
public void Execute(string unitTestRoot, IEnumerable <ServiceConfiguration> serviceConfigurations, bool useDllReference) { foreach (var configuration in _configurations) { string projectName = string.Format("AWSSDK.UnitTests.{0}.csproj", configuration.Name); string projectGuid = Utils.GetProjectGuid(Path.Combine(unitTestRoot, projectName)); IList <ProjectFileCreator.ProjectReference> commonReferences; IList <ProjectFileCreator.ProjectReference> serviceProjectReferences; IList <ProjectFileCreator.Reference> dllProjectReferences; if (useDllReference) { projectName = string.Format("AWSSDK.UnitTests.{0}.partial.csproj", configuration.Name); serviceProjectReferences = null; dllProjectReferences = ServiceDllReferences(unitTestRoot, serviceConfigurations, configuration.Name); } else { serviceProjectReferences = ServiceProjectReferences(unitTestRoot, serviceConfigurations, configuration.Name); dllProjectReferences = null; } commonReferences = GetCommonReferences(unitTestRoot, configuration.Name, useDllReference); var session = new Dictionary <string, object> { { "ProjectGuid", projectGuid }, { "RootNamespace", string.Format("AWSSDK_Dot{0}.UnitTests", configuration.Name) }, { "AssemblyName", string.Format("AWSSDK.UnitTests.{0}", configuration.Name) }, { "DebugOutputPath", string.Format(@"bin\Debug\{0}", configuration.Name.ToLower()) }, { "ReleaseOutputPath", string.Format(@"bin\Release\{0}", configuration.Name.ToLower()) }, { "ReleaseDefineConstants", configuration.DefineConstants }, { "DebugDefineConstants", "DEBUG;" + configuration.DefineConstants }, { "Reference", configuration.References }, { "CompileInclude", configuration.CompileInclude }, { "CommonReferences", commonReferences }, { "ServiceProjectReferences", serviceProjectReferences }, { "ServiceDllReferences", dllProjectReferences }, }; GenerateProjectFile(session, unitTestRoot, projectName); } }
private IList <ProjectFileCreator.ProjectReference> GetCommonReferences(string unitTestRoot, string projectType, bool useDllReference) { IList <ProjectFileCreator.ProjectReference> references = new List <ProjectFileCreator.ProjectReference>(); // // Core project reference // if (!useDllReference) { string coreProjectName = string.Format("AWSSDK.Core.{0}", projectType); string coreIncludePath = Path.Combine("..", "..", "src", "Core", coreProjectName + ".csproj"); string coreProjectPath = Path.Combine(unitTestRoot, coreIncludePath); references.Add(new ProjectFileCreator.ProjectReference { Name = coreProjectName, IncludePath = coreIncludePath, ProjectGuid = Utils.GetProjectGuid(coreProjectPath) }); } else { // if adding all serices as dll refernece, add core dll as a dll reference in ServiceDllReferences() } // // CommonTest project reference // string commonTestProjectName = string.Format("AWSSDK.CommonTest.{0}", projectType); string commonTestIncludePath = Path.Combine("..", "Common", commonTestProjectName + ".csproj"); string commonTestPath = Path.Combine(unitTestRoot, commonTestIncludePath); references.Add(new ProjectFileCreator.ProjectReference { Name = commonTestProjectName, IncludePath = commonTestIncludePath, ProjectGuid = Utils.GetProjectGuid(commonTestPath) }); return(references); }
void SetupProjectFile(string codeAnalysisRoot, ServiceConfiguration serviceConfiguration) { if (!Directory.Exists(codeAnalysisRoot)) { Directory.CreateDirectory(codeAnalysisRoot); } var assemblyName = "AWSSDK." + serviceConfiguration.Namespace.Split('.')[1] + ".CodeAnalysis"; var projectFilename = string.Concat(assemblyName, ".csproj"); string projectGuid; if (File.Exists(Path.Combine(codeAnalysisRoot, projectFilename))) { Console.WriteLine("...updating existing project file {0}", projectFilename); var projectPath = Path.Combine(codeAnalysisRoot, projectFilename); projectGuid = Utils.GetProjectGuid(projectPath); } else { projectGuid = Utils.NewProjectGuid; Console.WriteLine("...creating project file {0}", projectFilename); } var templateSession = new Dictionary <string, object>(); templateSession["ProjectGuid"] = projectGuid; templateSession["RootNamespace"] = serviceConfiguration.Namespace + ".CodeAnalysis"; templateSession["AssemblyName"] = assemblyName; templateSession["SourceDirectories"] = GetProjectSourceFolders(codeAnalysisRoot); templateSession["EmbeddedResources"] = GetEmbeddedResources(codeAnalysisRoot); CodeAnalysisProjectFile generator = new CodeAnalysisProjectFile(); generator.Session = templateSession; var generatedContent = generator.TransformText(); GeneratorDriver.WriteFile(codeAnalysisRoot, string.Empty, projectFilename, generatedContent); }
public void Execute(string unitTestRoot, IEnumerable <ServiceConfiguration> serviceConfigurations, bool useDllReference) { foreach (var configuration in _configurations) { IList <ProjectFileCreator.ProjectReference> projectReferences; IList <ProjectFileCreator.ProjectReference> serviceProjectReferences; string projectName; if (_isLegacyProj) { projectName = string.Format("AWSSDK.UnitTests.{0}.csproj", configuration.Name); serviceProjectReferences = new List <ProjectFileCreator.ProjectReference>() { new ProjectFileCreator.ProjectReference { IncludePath = $@"..\..\src\Services\*\*.{configuration.Name}.csproj" }, new ProjectFileCreator.ProjectReference { IncludePath = $@"..\..\test\Services\*\*.{configuration.Name}.csproj" } }; } else { projectName = string.Format("AWSSDK.UnitTests.{0}.{1}.csproj", _serviceName, configuration.Name); serviceProjectReferences = ServiceProjectReferences(unitTestRoot, serviceConfigurations, configuration.Name); } string projectGuid = Utils.GetProjectGuid(Path.Combine(unitTestRoot, projectName)); projectReferences = GetCommonReferences(unitTestRoot, configuration.Name, useDllReference); var projectProperties = new Project() { TargetFrameworks = configuration.TargetFrameworkVersions, DefineConstants = configuration.CompilationConstants.Concat(new string[] { "DEBUG" }).ToList(), ReferenceDependencies = configuration.DllReferences, CompileRemoveList = configuration.PlatformExcludeFolders, Services = configuration.VisualStudioServices, FrameworkPathOverride = configuration.FrameworkPathOverride, PackageReferences = configuration.PackageReferences, SupressWarnings = configuration.NoWarn, OutputPathOverride = configuration.OutputPathOverride, SignBinaries = false }; if (_isLegacyProj) { projectProperties.AssemblyName = string.Format("AWSSDK.UnitTests.{0}", configuration.Name); projectProperties.IndividualFileIncludes = new List <string> { "../Services/*/UnitTests/**/*.cs" }; projectProperties.EmbeddedResources = configuration.EmbeddedResources; projectProperties.FxcopAnalyzerRuleSetFilePath = @"..\..\AWSDotNetSDK.ruleset"; projectProperties.FxcopAnalyzerRuleSetFilePathForBuild = @"..\..\AWSDotNetSDKForBuild.ruleset"; } else { projectProperties.AssemblyName = string.Format("AWSSDK.UnitTests.{0}.{1}", _serviceName, configuration.Name); //Check for embedded resources var embeddedResourcePath = Path.Combine(unitTestRoot, "Custom", "EmbeddedResource"); if (Directory.Exists(embeddedResourcePath)) { projectProperties.EmbeddedResources = new List <string> { Path.Combine("Custom", "EmbeddedResource", "*") }; } projectProperties.FxcopAnalyzerRuleSetFilePath = @"..\..\..\..\AWSDotNetSDK.ruleset"; projectProperties.FxcopAnalyzerRuleSetFilePathForBuild = @"..\..\..\..\AWSDotNetSDKForBuild.ruleset"; } if (serviceProjectReferences != null) { Array.ForEach(serviceProjectReferences.ToArray(), x => projectReferences.Add(x)); } // For S3's Multi-Region Access Points, multiple unit tests rely on SigV4a signing provided by the CRT, // which is not a dependency for all users of S3 so we must add this directly to the generated UnitTest projects // (either the full ones or S3-specific UnitTest.csprojs). // // Once CRT integration is more widespread, this should likely be done for all services // via _manifest.json and this S3-specific case removed. if (_serviceName == "S3") { var crtExtensionAsProjectReference = new ProjectFileCreator.ProjectReference { Name = string.Format("AWSSDK.Extensions.CrtIntegration.{0}", configuration.Name), IncludePath = Path.Combine(new string[] { "..", "..", "..", "..", "..", "extensions", "src", "AWSSDK.Extensions.CrtIntegration", $"AWSSDK.Extensions.CrtIntegration.{configuration.Name}.csproj" }) }; projectReferences.Add(crtExtensionAsProjectReference); } else if (_isLegacyProj) // unit test projects with all services, which need CRT also but have a different relative path { var crtExtensionAsProjectReference = new ProjectFileCreator.ProjectReference { Name = string.Format("AWSSDK.Extensions.CrtIntegration.{0}", configuration.Name), IncludePath = Path.Combine(new string[] { "..", "..", "..", "extensions", "src", "AWSSDK.Extensions.CrtIntegration", $"AWSSDK.Extensions.CrtIntegration.{configuration.Name}.csproj" }) }; projectReferences.Add(crtExtensionAsProjectReference); } projectProperties.ProjectReferences = projectReferences; GenerateProjectFile(projectProperties, unitTestRoot, projectName); } }
public void Execute(string unitTestRoot, IEnumerable <ServiceConfiguration> serviceConfigurations, bool useDllReference) { foreach (var configuration in _configurations) { IList <ProjectFileCreator.ProjectReference> projectReferences; IList <ProjectFileCreator.ProjectReference> serviceProjectReferences; string projectName; if (_isLegacyProj) { projectName = string.Format("AWSSDK.UnitTests.{0}.csproj", configuration.Name); serviceProjectReferences = new List <ProjectFileCreator.ProjectReference>() { new ProjectFileCreator.ProjectReference { IncludePath = $@"..\..\src\Services\*\*.{configuration.Name}.csproj" }, new ProjectFileCreator.ProjectReference { IncludePath = $@"..\..\test\Services\*\*.{configuration.Name}.csproj" } }; } else { projectName = string.Format("AWSSDK.UnitTests.{0}.{1}.csproj", _serviceName, configuration.Name); serviceProjectReferences = ServiceProjectReferences(unitTestRoot, serviceConfigurations, configuration.Name); } string projectGuid = Utils.GetProjectGuid(Path.Combine(unitTestRoot, projectName)); projectReferences = GetCommonReferences(unitTestRoot, configuration.Name, useDllReference); var projectProperties = new Project() { TargetFrameworks = configuration.TargetFrameworkVersions, DefineConstants = configuration.CompilationConstants.Concat(new string[] { "DEBUG" }).ToList(), ReferenceDependencies = configuration.DllReferences, CompileRemoveList = configuration.PlatformExcludeFolders, Services = configuration.VisualStudioServices, FrameworkPathOverride = configuration.FrameworkPathOverride, PackageReferences = configuration.PackageReferences, SupressWarnings = configuration.NoWarn, OutputPathOverride = configuration.OutputPathOverride, SignBinaries = false }; if (_isLegacyProj) { projectProperties.AssemblyName = string.Format("AWSSDK.UnitTests.{0}", configuration.Name); projectProperties.IndividualFileIncludes = new List <string> { "../Services/*/UnitTests/**/*.cs" }; projectProperties.EmbeddedResources = configuration.EmbeddedResources; projectProperties.FxcopAnalyzerRuleSetFilePath = @"..\..\AWSDotNetSDK.ruleset"; projectProperties.FxcopAnalyzerRuleSetFilePathForBuild = @"..\..\AWSDotNetSDKForBuild.ruleset"; } else { projectProperties.AssemblyName = string.Format("AWSSDK.UnitTests.{0}.{1}", _serviceName, configuration.Name); //Check for embedded resources var embeddedResourcePath = Path.Combine(unitTestRoot, "Custom", "EmbeddedResource"); if (Directory.Exists(embeddedResourcePath)) { projectProperties.EmbeddedResources = new List <string> { Path.Combine("Custom", "EmbeddedResource", "*") }; } projectProperties.FxcopAnalyzerRuleSetFilePath = @"..\..\..\..\AWSDotNetSDK.ruleset"; projectProperties.FxcopAnalyzerRuleSetFilePathForBuild = @"..\..\..\..\AWSDotNetSDKForBuild.ruleset"; } if (serviceProjectReferences != null) { Array.ForEach(serviceProjectReferences.ToArray(), x => projectReferences.Add(x)); } projectProperties.ProjectReferences = projectReferences; GenerateProjectFile(projectProperties, unitTestRoot, projectName); } }
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; if (projectFileConfiguration.Template.Equals("VS2017ProjectFile", StringComparison.InvariantCultureIgnoreCase)) { // for vs2017 projects, skip csproject generation } else { 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); } } }
/// <summary> /// Creates the platform-specific project files for the given service configuration /// </summary> /// <param name="serviceFilesRoot">The folder under which all of the source files for the service will exist</param> /// <param name="serviceConfiguration"></param> /// <param name="projectFileConfigurations"></param> public void Execute(string serviceFilesRoot, ServiceConfiguration serviceConfiguration, IEnumerable <ProjectFileConfiguration> projectFileConfigurations) { CreatedProjectFiles = new Dictionary <string, ProjectConfigurationData>(); var assemblyName = "AWSSDK." + serviceConfiguration.Namespace.Split('.')[1]; foreach (var projectFileConfiguration in projectFileConfigurations) { var projectType = projectFileConfiguration.Name; if (projectType.Equals("Unity", StringComparison.InvariantCultureIgnoreCase) && !serviceConfiguration.SupportedInUnity) { continue; } if (projectType.Equals("CoreCLR", StringComparison.InvariantCultureIgnoreCase) && !serviceConfiguration.CoreCLRSupport) { continue; } if (projectFileConfiguration.Template.Equals("VS2017ProjectFile", StringComparison.InvariantCultureIgnoreCase)) { var projectReferenceList = new List <ProjectReference>(); foreach (var dependency in serviceConfiguration.ServiceDependencies.Keys) { if (string.Equals(dependency, "Core", StringComparison.InvariantCultureIgnoreCase)) { continue; } projectReferenceList.Add(new ProjectReference { IncludePath = string.Format(@"..\..\Services\{0}\AWSSDK.{1}.{2}.csproj", dependency, dependency, projectType) }); } projectReferenceList.Add(new ProjectReference { IncludePath = string.Format(@"..\..\Core\AWSSDK.Core.{0}.csproj", projectType) }); projectFileConfiguration.ProjectReferences = projectReferenceList; GenerateVS2017ProjectFile(serviceFilesRoot, serviceConfiguration, projectFileConfiguration); continue; } if (projectFileConfiguration.IsSubProfile && !(serviceConfiguration.PclVariants != null && serviceConfiguration.PclVariants.Any(p => p.Equals(projectFileConfiguration.Name)))) { // Skip sub profiles for service projects. continue; } var projectFilename = string.Concat(assemblyName, ".", projectType, ".csproj"); bool newProject = false; string projectGuid; if (File.Exists(Path.Combine(serviceFilesRoot, projectFilename))) { Console.WriteLine("...updating existing project file {0}", projectFilename); var projectPath = Path.Combine(serviceFilesRoot, 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"] = serviceConfiguration.Namespace; templateSession["AssemblyName"] = assemblyName; templateSession["SourceDirectories"] = GetProjectSourceFolders(projectFileConfiguration, serviceFilesRoot); 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>(); if (serviceConfiguration.ServiceDependencies != null) { foreach (var dependency in serviceConfiguration.ServiceDependencies) { var pt = projectType; if (!(pt.StartsWith(@"Net") || pt.StartsWith(@"Unity")) && serviceConfiguration.UsePclProjectDependencies) { pt = @"PCL"; } var dependencyProjectName = "AWSSDK." + dependency.Key + "." + pt; string dependencyProject; if (string.Equals(dependency.Key, "Core", StringComparison.InvariantCultureIgnoreCase)) { dependencyProject = string.Concat(@"..\..\", dependency.Key, "\\", dependencyProjectName, ".csproj"); } else { dependencyProject = string.Concat(@"..\", dependency.Key, "\\", dependencyProjectName, ".csproj"); } projectReferences.Add(new ProjectReference { IncludePath = dependencyProject, ProjectGuid = Utils.GetProjectGuid(Path.Combine(serviceFilesRoot, dependencyProject)), Name = dependencyProjectName }); } } templateSession["ProjectReferences"] = projectReferences.OrderBy(x => x.Name).ToList(); templateSession["UnityPath"] = Options.UnityPath; if (serviceConfiguration.ModelName.Equals("s3", StringComparison.OrdinalIgnoreCase) && projectType == "Net45") { templateSession["SystemReferences"] = new List <string> { "System.Net.Http" }; } if (serviceConfiguration.ReferenceDependencies != null && serviceConfiguration.ReferenceDependencies.ContainsKey(projectFileConfiguration.Name)) { templateSession["ReferenceDependencies"] = serviceConfiguration.ReferenceDependencies[projectFileConfiguration.Name]; templateSession["NuGetTargetFramework"] = projectFileConfiguration.NuGetTargetPlatform; } GenerateProjectFile(projectFileConfiguration, projectConfigurationData, templateSession, serviceFilesRoot, projectFilename); } }
public void Execute(string unitTestRoot, IEnumerable <ServiceConfiguration> serviceConfigurations, bool useDllReference) { foreach (var configuration in _configurations) { string projectName; if (_isLegacyProj) { projectName = string.Format("AWSSDK.UnitTests.{0}.csproj", configuration.Name); } else { projectName = string.Format("AWSSDK.UnitTests.{0}.{1}.csproj", _serviceName, configuration.Name); } string projectGuid = Utils.GetProjectGuid(Path.Combine(unitTestRoot, projectName)); IList <ProjectFileCreator.ProjectReference> commonReferences; IList <ProjectFileCreator.ProjectReference> serviceProjectReferences; serviceProjectReferences = ServiceProjectReferences(unitTestRoot, serviceConfigurations, configuration.Name); commonReferences = GetCommonReferences(unitTestRoot, configuration.Name, useDllReference); var session = new Dictionary <string, object> { { "TargetFramework", configuration.TargetFrameworkVersion }, { "DefineConstants", "DEBUG;" + configuration.CompilationConstants }, { "Reference", configuration.FrameworkReferences }, { "CompileRemoveList", configuration.PlatformExcludeFolders }, { "Services", configuration.VisualStudioServices }, { "ReferencePath", configuration.ReferencePath }, { "FrameworkPathOverride", configuration.FrameworkPathOverride }, { "FrameworkReferences", configuration.FrameworkReferences }, { "PackageReferenceList", configuration.PackageReferences }, { "NoWarn", configuration.NoWarn }, { "OutputPathOverride", configuration.OutputPathOverride }, { "SignBinaries", false }, { "ConfigurationName", configuration.Name } }; if (_isLegacyProj) { session["AssemblyName"] = string.Format("AWSSDK.UnitTests.{0}", configuration.Name); session["ExternalFilesInclude"] = "../Services/*/UnitTests/**/*.cs"; session["EmbeddedResources"] = configuration.EmbeddedResources; } else { session["AssemblyName"] = string.Format("AWSSDK.UnitTests.{0}.{1}", _serviceName, configuration.Name); //Check for embedded resources var embeddedResourcePath = Path.Combine(unitTestRoot, "Custom", "EmbeddedResource"); if (Directory.Exists(embeddedResourcePath)) { session["EmbeddedResources"] = new List <string> { Path.Combine("Custom", "EmbeddedResource", "*") }; } } if (serviceProjectReferences != null) { session["ProjectReferenceList"] = commonReferences.Concat(serviceProjectReferences).ToList(); } else { session["ProjectReferenceList"] = commonReferences; } GenerateProjectFile(session, unitTestRoot, projectName); } }
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; if (projectFileConfiguration.Template.Equals("VS2017ProjectFile", StringComparison.InvariantCultureIgnoreCase)) { // for vs2017 projects, skip csproject generation } else { 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 projectProperties = new Project(); projectProperties.Name = projectFileConfiguration.Name; projectProperties.ProjectGuid = projectGuid; projectProperties.RootNamespace = "Amazon"; projectProperties.AssemblyName = assemblyName; projectProperties.SourceDirectories = GetCoreProjectSourceFolders(projectFileConfiguration, coreFilesRoot); projectProperties.IndividualFileIncludes = new List <string> { "endpoints.json", }; projectProperties.KeyFilePath = @"..\..\awssdk.dll.snk"; projectProperties.SupressWarnings = "419,1570,1591"; projectProperties.NugetPackagesLocation = @"..\..\packages\"; projectProperties.FxcopAnalyzerRuleSetFilePath = @"..\..\AWSDotNetSDK.ruleset"; projectProperties.FxcopAnalyzerRuleSetFilePathForBuild = @"..\..\AWSDotNetSDKForBuild.ruleset"; projectProperties.TargetFrameworks = projectFileConfiguration.TargetFrameworkVersions; projectProperties.DefineConstants = projectFileConfiguration.CompilationConstants; projectProperties.BinSubfolder = projectFileConfiguration.BinSubFolder; projectProperties.PackageReferences = projectFileConfiguration.PackageReferences; projectProperties.CustomRoslynAnalyzersDllDirectory = @"..\..\..\buildtools\CustomRoslynAnalyzers.dll"; var projectConfigurationData = new ProjectConfigurationData { ProjectGuid = projectGuid }; var projectName = Path.GetFileNameWithoutExtension(projectFilename); if (newProject) { CreatedProjectFiles[projectName] = projectConfigurationData; } var projectReferences = new List <ProjectReference>(); projectProperties.ProjectReferences = projectReferences.OrderBy(x => x.Name).ToList(); GenerateProjectFile(projectFileConfiguration, projectConfigurationData, projectProperties, coreFilesRoot, projectFilename); } } }
/// <summary> /// Creates the platform-specific project files for the given service configuration /// </summary> /// <param name="serviceFilesRoot">The folder under which all of the source files for the service will exist</param> /// <param name="serviceConfiguration"></param> /// <param name="projectFileConfigurations"></param> public void Execute(string serviceFilesRoot, ServiceConfiguration serviceConfiguration, IEnumerable <ProjectFileConfiguration> projectFileConfigurations) { CreatedProjectFiles = new Dictionary <string, ProjectConfigurationData>(); var assemblyName = "AWSSDK." + serviceConfiguration.Namespace.Split('.')[1]; foreach (var projectFileConfiguration in projectFileConfigurations) { var projectType = projectFileConfiguration.Name; if (projectType.Equals("NetStandard", StringComparison.InvariantCultureIgnoreCase) && !serviceConfiguration.NetStandardSupport) { continue; } if (projectFileConfiguration.Template.Equals("VS2017ProjectFile", StringComparison.InvariantCultureIgnoreCase)) { var projectReferenceList = new List <ProjectReference>(); foreach (var dependency in serviceConfiguration.ServiceDependencies.Keys) { if (string.Equals(dependency, "Core", StringComparison.InvariantCultureIgnoreCase)) { continue; } projectReferenceList.Add(new ProjectReference { IncludePath = string.Format(@"..\..\Services\{0}\AWSSDK.{1}.{2}.csproj", dependency, dependency, projectType) }); } var corePath = @"..\..\Core\AWSSDK.Core.{0}.csproj"; if (serviceConfiguration.IsTestService) { corePath = @"..\..\..\src\Core\AWSSDK.Core.{0}.csproj"; } projectReferenceList.Add(new ProjectReference { IncludePath = string.Format(corePath, projectType) }); projectFileConfiguration.ProjectReferences = projectReferenceList; GenerateVS2017ProjectFile(serviceFilesRoot, serviceConfiguration, projectFileConfiguration); continue; } var projectFilename = string.Concat(assemblyName, ".", projectType, ".csproj"); bool newProject = false; string projectGuid; if (File.Exists(Path.Combine(serviceFilesRoot, projectFilename))) { Console.WriteLine("...updating existing project file {0}", projectFilename); var projectPath = Path.Combine(serviceFilesRoot, projectFilename); projectGuid = Utils.GetProjectGuid(projectPath); } else { newProject = true; projectGuid = Utils.NewProjectGuid; Console.WriteLine("...creating project file {0}", projectFilename); } var projectProperties = new Project(); projectProperties.Name = projectFileConfiguration.Name; projectProperties.ProjectGuid = projectGuid; projectProperties.RootNamespace = serviceConfiguration.Namespace; projectProperties.AssemblyName = assemblyName; projectProperties.SourceDirectories = GetProjectSourceFolders(projectFileConfiguration, serviceFilesRoot); projectProperties.NugetPackagesLocation = @"..\..\..\packages\"; projectProperties.FxcopAnalyzerRuleSetFilePath = @"..\..\..\AWSDotNetSDK.ruleset"; projectProperties.FxcopAnalyzerRuleSetFilePathForBuild = @"..\..\..\AWSDotNetSDKForBuild.ruleset"; projectProperties.TargetFrameworks = projectFileConfiguration.TargetFrameworkVersions; projectProperties.DefineConstants = projectFileConfiguration.CompilationConstants; projectProperties.BinSubfolder = projectFileConfiguration.BinSubFolder; projectProperties.PackageReferences = projectFileConfiguration.PackageReferences; projectProperties.CustomRoslynAnalyzersDllDirectory = @"..\..\..\..\buildtools\CustomRoslynAnalyzers.dll"; var projectConfigurationData = new ProjectConfigurationData { ProjectGuid = projectGuid }; var projectName = Path.GetFileNameWithoutExtension(projectFilename); if (newProject) { CreatedProjectFiles[projectName] = projectConfigurationData; } var projectReferences = new List <ProjectReference>(); if (serviceConfiguration.ServiceDependencies != null) { foreach (var dependency in serviceConfiguration.ServiceDependencies) { var dependencyProjectName = "AWSSDK." + dependency.Key + "." + projectType; string dependencyProject; if (string.Equals(dependency.Key, "Core", StringComparison.InvariantCultureIgnoreCase)) { dependencyProject = string.Concat(@"..\..\", dependency.Key, "\\", dependencyProjectName, ".csproj"); } else { dependencyProject = string.Concat(@"..\", dependency.Key, "\\", dependencyProjectName, ".csproj"); } projectReferences.Add(new ProjectReference { IncludePath = dependencyProject, ProjectGuid = Utils.GetProjectGuid(Path.Combine(serviceFilesRoot, dependencyProject)), Name = dependencyProjectName }); } } projectProperties.ProjectReferences = projectReferences.OrderBy(x => x.Name).ToList(); if (serviceConfiguration.ReferenceDependencies != null && serviceConfiguration.ReferenceDependencies.ContainsKey(projectFileConfiguration.Name)) { projectProperties.ReferenceDependencies = serviceConfiguration.ReferenceDependencies[projectFileConfiguration.Name]; } GenerateProjectFile(projectFileConfiguration, projectConfigurationData, projectProperties, serviceFilesRoot, projectFilename); } }