private void RegisterPostBuildTasks(IProjectConfiguration projConfig) { this.Context.PostBuildTask(projConfig.ProjectAlias); this.Context.PostBuildTask("MoveToBuildTemp", false, projConfig.ProjectAlias) .Does(() => { if (projConfig.BuildTempDirectory == null) { throw new ArgumentNullException(nameof(projConfig.BuildTempDirectory), "BuildTempDirectory was not set on ProjectConfig"); } var artifacts = projConfig.GetSrcProjectArtifacts(); var filePaths = artifacts as FilePath[] ?? artifacts.ToArray(); if (!filePaths.Any()) { throw new Exception($"No Build Artifacts found. Run \"build.(ps1|.sh) -r=Build-{projConfig.ProjectAlias}"); } this.Context.EnsureDirectoryExists(projConfig.BuildTempDirectory); foreach (var artifact in filePaths) { this.Context.CopyFileToDirectory(artifact, projConfig.BuildTempDirectory); } }); }
public IProject?Construct(IProjectConfiguration config) { var buildConnectionNames = string.Join(", ", config.BuildConnectionNames); Log.Debug().Message($"Trying to construct project from {buildConnectionNames} and {config.SourceControlConnectionName}").Write(); var buildProviders = new List <IBuildProvider>(); foreach (var connectionName in config.BuildConnectionNames) { var buildProvider = BuildProvider(connectionName); if (buildProvider == null) { ReportError("FailedToConstructBuildProviderForConnection", connectionName); return(null); } buildProviders.Add(buildProvider); } IBranchProvider?branchProvider = null; if (!string.IsNullOrEmpty(config.SourceControlConnectionName)) { branchProvider = BranchProvider(config.SourceControlConnectionName); } if (branchProvider != null) { return(new Project(buildProviders, branchProvider, config)); } ReportError("FailedToConstructBranchProviderForConnection", config.SourceControlConnectionName); return(null); }
/// <summary> /// Gets relative sln file path to current working directory /// </summary> /// <param name="config">ProjectConfiguration</param> /// <returns>Relative Sln FilePath</returns> public static FilePath GetRelativeSlnFilePath(this IProjectConfiguration config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } return(config.Context.MakeRelative(config.SlnFilePath)); }
/// <summary> /// Gets unique name for the build scenario. /// One software project may have several build scenarios, e.g. V3.Storage, V3.Storage-FirstBranch, V3.Storage.SecondBranch, etc. /// </summary> public static string UniqueName(this IProjectConfiguration config) { if (String.IsNullOrEmpty(config.Branch)) { return(config.Name); } return($"{config.Name}-{config.Branch}"); }
public Project(IEnumerable <IBuildProvider> buildProviders, IBranchProvider?branchProvider, IProjectConfiguration config) { Name = config.ProjectName; _buildProviders = buildProviders.ToList(); _branchProvider = branchProvider; Config = config; _buildFilter = new ListBuildFilter(config, BranchNameExtractor); }
public override Task Initialize(Project project, IProjectConfiguration configuration, Compilation compilation) { var taskSymbol = compilation.References .Select(compilation.GetAssemblyOrModuleSymbol) .OfType <IAssemblySymbol>() .Select(assemblySymbol => assemblySymbol.GetTypeByMetadataName("System.Threading.Tasks.Task")) .FirstOrDefault(o => o != null); if (taskSymbol == null) { throw new InvalidOperationException("Unable to find System.Threading.Tasks.Task type"); } // Get member: // Task WhenAll(IEnumerable<Task> tasks) _whenAllMethod = taskSymbol.GetMembers("WhenAll").OfType <IMethodSymbol>() .First(o => o.Parameters.Length == 1 && !o.IsGenericMethod && !o.Parameters[0].IsParams); var parallelSymbol = compilation.References .Select(compilation.GetAssemblyOrModuleSymbol) .OfType <IAssemblySymbol>() .Select(assemblySymbol => assemblySymbol.GetTypeByMetadataName("System.Threading.Tasks.Parallel")) .FirstOrDefault(o => o != null); if (parallelSymbol == null) { return(Task.CompletedTask); } // Try to get member: // ParallelLoopResult ForEach<TSource>(IEnumerable<TSource> source, Action<TSource> body) _forEachMethod = parallelSymbol.GetMembers("ForEach").OfType <IMethodSymbol>() .FirstOrDefault(o => o.Parameters.Length == 2 && o.Parameters[0].Type.Name == "IEnumerable" && o.Parameters[1].Type is INamedTypeSymbol namedType && namedType.IsGenericType && namedType.TypeArguments.Length == 1 // Action<TSource> ); // Try to get member // ParallelLoopResult For(int fromInclusive, int toExclusive, Action<int> body) _forMethod = parallelSymbol.GetMembers("For").OfType <IMethodSymbol>() .FirstOrDefault(o => o.Parameters.Length == 3 && o.Parameters[0].Type.Name == "Int32" && o.Parameters[2].Type is INamedTypeSymbol namedType && namedType.IsGenericType && namedType.TypeArguments.Length == 1 // Action<int> or Action<long> ); return(Task.CompletedTask); }
private void WriteSetupPackages(IProjectConfiguration config) { var setup = config as ISetupPackages; if (setup == null) { return; } //xxx working on xproj here if (setup.ProjectExtension == "xproj") { return; } var args = new List <Arg> { new Arg("ProjectFile", setup.ProjectFilePath()), new Arg("PackagesPath", setup.PackagesDirectory()), new Arg("ReferencesPath", setup.ReferencesDirectory()), new Arg("TempPath", setup.TempDirectory()), new Arg("NuGetExecutable", "$(nugetExecutable)"), new Arg("NuGetUrl", setup.NugetRestoreUrl()) }; var related = config as IResolveRelated; if (related != null) { args.Add(new Arg("RelatedPath", related.RelatedDirectory())); } if (setup.CustomVersions != null) { args.Add(new Arg("CustomVersions", setup.CustomVersions)); } var bundle = config as IMakeBundle; if (bundle != null) { args.Add(new Arg("Bundles", bundle.Bundles)); } var nuget = config as INugetPackage; if (nuget != null) { args.Add(new Arg("Dependencies", nuget.Dependencies)); } ExecTaskLegacy( "$(ccnetBuildSetupPackages)", "Setup packages", args.ToArray()); }
public Task Initialize(Project project, IProjectConfiguration configuration, Compilation compilation) { _configuration = configuration.TransformConfiguration.DocumentationComments; _isEnabled = _configuration.CanRemoveMethodRemarks != null || _configuration.CanRemoveMethodSummary != null || _configuration.AddOrReplaceMethodRemarks != null || _configuration.AddOrReplaceMethodSummary != null ; return(Task.CompletedTask); }
public Task Initialize(Project project, IProjectConfiguration configuration, Compilation compilation) { _configuration = configuration.TransformConfiguration.DocumentationComments; _isEnabledForPartialTypes = _configuration.AddOrReplacePartialTypeComments != null || _configuration.RemovePartialTypeComments != null; _isEnabledForNewTypes = _configuration.AddOrReplaceNewTypeComments != null || _configuration.RemoveNewTypeComments != null ; _cachedComments.Clear(); return(Task.CompletedTask); }
/// <summary> /// Adds test config to project and returns that test config /// </summary> /// <param name="projConfig">ProjectConfiguration</param> /// <param name="testCategory">Test Category (Unit, System, etc)</param> /// <returns>TestConfiguration</returns> /// <example> /// <code> /// // Creates task "Clean-Build-Sln" /// AddDotNetCoreProject("./my.sln", config => /// { /// config.Framework = "net452"; /// config.AddTestConfig("Unit", testConfig => /// { /// testConfig.Logger = "teamcity"; /// }); /// }); /// </code> /// </example> public static ITestConfiguration AddTestConfig(this IProjectConfiguration projConfig, string testCategory) { if (projConfig == null) { throw new ArgumentNullException(nameof(projConfig)); } var testConfig = new TestConfiguration(projConfig.Context, testCategory); projConfig.AddTestConfig(testConfig); return(testConfig); }
public void Write(IProjectConfiguration config) { Comment($"PROJECT: {config.UniqueName()}"); using (Tag("project")) { WriteProjectHeader(config); WriteSourceControl(config); WriteTriggers(config); WritePrebuild(config); WriteTasks(config); WritePublishers(config); } }
public async Task Initialize(Project project, IProjectConfiguration configuration, Compilation compilation) { var extProject = project.Solution.Projects.First(o => o.Name == _projectName); var doc = extProject.Documents.First(o => o.Name == _fileName); var rootNode = await doc.GetSyntaxRootAsync().ConfigureAwait(false); var semanticModel = await doc.GetSemanticModelAsync().ConfigureAwait(false); _extensionMethods = new HashSet <IMethodSymbol>(rootNode.DescendantNodes() .OfType <MethodDeclarationSyntax>() .Where(o => o.Identifier.ValueText.EndsWith("Async")) .Select(o => semanticModel.GetDeclaredSymbol(o))); _extensionMethodsLookup = _extensionMethods.ToLookup(o => o.Name); }
internal static IEnumerable <string> GetAllProjectOutputDirectoryPaths( this IProjectConfiguration config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } var paths = config.AllProjects .SelectMany(t => t.GetProjectOutputDirectoryPaths(config)) .Distinct(); return(paths); }
private void WriteSaveSnapshot(IProjectConfiguration config) { var snapshot = config as ISaveSnapshot; if (snapshot == null) { return; } using (CbTag("AppendToFile")) { Attr("file", snapshot.TempFileExcludeFromSnapshot()); Attr("text", "$tf"); } using (CbTag("AppendToFile")) { Attr("file", snapshot.TempFileExcludeFromSnapshot()); Attr("text", "*.nupkg"); } var source = config as ISourceDirectory; if (source != null) { using (CbTag("CompressDirectoryExclude")) { Attr("path", source.SourceDirectory()); Attr("output", snapshot.SnapshotSourceFile()); Attr("exclude", snapshot.TempFileExcludeFromSnapshot()); } AzureUpload(config, "snapshot", snapshot.SnapshotSourceFile()); } var packages = config as IPackagesDirectory; if (packages != null) { using (CbTag("CompressDirectoryExclude")) { Attr("path", packages.PackagesDirectory()); Attr("output", snapshot.SnapshotPackagesFile()); Attr("exclude", snapshot.TempFileExcludeFromSnapshot()); } AzureUpload(config, "snapshot", snapshot.SnapshotPackagesFile()); } }
private void RegisterPreBuildTasks(IProjectConfiguration projConfig) { this.Context.PreBuildTask(projConfig.ProjectAlias); this.Context.PreBuildTask("DotNetCoreRestore", false, projConfig.ProjectAlias) .Does(() => { var restoreSettings = new DotNetCoreRestoreSettings { Sources = this._helperSettings.DotNetCoreSettings.NugetSettings.GetFeedUrls().ToList() }; this.Context.DotNetCoreRestore(projConfig.GetRelativeSlnFilePath().FullPath, restoreSettings); }); }
private void WritePublishFabric(IProjectConfiguration config) { var fabric = config as FabricApplicationProjectConfiguration; if (fabric == null) { return; } using (CbTag("CopyFiles")) { Attr("from", $@"{fabric.SourceDirectoryPackage()}\*"); Attr("to", fabric.TempDirectoryPublish()); } }
public override Task Initialize(Project project, IProjectConfiguration configuration, Compilation compilation) { var taskSymbol = compilation.References .Select(compilation.GetAssemblyOrModuleSymbol) .OfType <IAssemblySymbol>() .Select(assemblySymbol => assemblySymbol.GetTypeByMetadataName("System.Threading.Tasks.Task")) .FirstOrDefault(o => o != null); if (taskSymbol == null) { throw new InvalidOperationException("Unable to find System.Threading.Tasks.Task type"); } _taskDelayMethods = taskSymbol.GetMembers("Delay").OfType <IMethodSymbol>().ToList(); return(Task.CompletedTask); }
private void AzureUpload(IProjectConfiguration config, string container, string localFile, bool includeVersion = true) { var fileName = Path.GetFileName(localFile); var blobFile = includeVersion ? $"{config.UniqueName()}/$[$CCNetLabel]/{fileName}" : $"{config.UniqueName()}/{fileName}"; ExecTaskLegacy( "$(ccnetBuildAzureUpload)", $@"Upload ""{fileName}"" to ""{container}""", new Arg("Storage", "Devbuild"), new Arg("Container", container), new Arg("LocalFile", localFile), new Arg("BlobFile", blobFile)); }
private void RegisterTestTasks(IProjectConfiguration projConfig, ITestConfiguration testConfig) { this.Context.TestCleanTask(projConfig.ProjectAlias, testConfig.TestCategory) .Does(() => { var targetDir = this.Context.MakeAbsolute(this.TestTempFolder); targetDir = targetDir.Combine(projConfig.ProjectAlias); targetDir = targetDir.Combine(testConfig.TestCategory); if (this.Context.DirectoryExists(targetDir)) { this.Context.DeleteDirectory(targetDir, true); } }); this.Context.TestTask(projConfig.ProjectAlias, testConfig.TestCategory) .Does(() => { var targetDir = this.Context.MakeAbsolute(this.TestTempFolder); targetDir = targetDir.Combine(projConfig.ProjectAlias); targetDir = targetDir.Combine(testConfig.TestCategory); var settings = new DotNetCoreTestSettings { Filter = testConfig.GetDotNetCoreCategoryString(), Configuration = projConfig.Configuration, Framework = projConfig.Framework, NoBuild = !this._helperSettings.RunAllDependencies }; foreach (var testProject in projConfig.TestProjects) { var logger = testConfig.Logger; if (string.IsNullOrWhiteSpace(testConfig.Logger)) { var testResultsFile = $"{testProject.Name}.{testConfig.TestCategory}.trx"; var testResultsTarget = targetDir.CombineWithFilePath(testResultsFile); logger = $"trx;LogFileName={testResultsTarget.FullPath}"; } settings.Logger = logger; this.Context.DotNetCoreTest(this.Context.MakeAbsolute(testProject.Path).FullPath, settings); } }); }
private void WriteCompleteBuild(IProjectConfiguration config) { var setup = config as ISetupPackages; if (setup != null) { AzureUpload(config, "build", setup.TempFilePackages()); } var prepare = config as IPrepareProject; if (prepare != null) { AzureUpload(config, "build", prepare.TempFileSource()); AzureUpload(config, "build", prepare.TempFileVersion(), false); } }
private void WriteNotifyProjects(IProjectConfiguration config) { var notify = config as INotifyProjects; if (notify == null) { return; } ExecTaskLegacy( "$(ccnetBuildNotifyProjects)", "Notify other projects", new Arg("ProjectName", config.Name), new Arg("BuildPath", "$(buildPath)"), new Arg("ServerNames", "Library|Website|Service|Application|Azure"), new Arg("ReferencesFolder", "references")); }
public Task Initialize(Project project, IProjectConfiguration configuration, Compilation compilation) { var assertSymbol = compilation.References .Select(compilation.GetAssemblyOrModuleSymbol) .OfType <IAssemblySymbol>() .Select(assemblySymbol => assemblySymbol.GetTypeByMetadataName("AsyncGenerator.TestCases.Runner")) .FirstOrDefault(o => o != null); if (assertSymbol == null) { throw new InvalidOperationException("Unable to find NUnit.Framework.Assert type"); } _asyncCounterpart = assertSymbol.GetMembers("RunGeneric").OfType <IMethodSymbol>().First(); return(Task.CompletedTask); }
private void RegisterBuildTasks(IProjectConfiguration projConfig) { this.Context.BuildTask(projConfig.ProjectAlias); this.Context.BuildTask("DotNetCoreBuild", false, projConfig.ProjectAlias) .Does(() => { var buildSettings = new DotNetCoreBuildSettings { Configuration = projConfig.Configuration, Framework = projConfig.Framework }; this.Context.Debug($"Building {projConfig.GetRelativeSlnFilePath().FullPath}..."); this.Context.DotNetCoreBuild(projConfig.GetRelativeSlnFilePath().FullPath, buildSettings); }); }
public static VCase ReadFrom(string filePath, IProjectConfiguration config) { var vCase = new VCase(); using (var stream = new StreamReader(filePath, Encoding.UTF8)) using (var xml = new XmlTextReader(stream)) { xml.ReadToFollowing("Case"); if (xml.ReadToFollowing("Name")) { vCase.Name = xml.ReadElementContentAsString(); } if (xml.ReadToFollowing("CaseItems")) { while (xml.ReadToFollowing("CaseItem")) { VCaseItem item = null; xml.ReadToFollowing("Id"); var id = xml.ReadElementContentAsString(); xml.ReadToFollowing("DisplayName"); var displayName = xml.ReadElementContentAsString(); xml.ReadToFollowing("RelativePath"); var relativePath = xml.ReadElementContentAsString(); xml.ReadToFollowing("Type"); var type = xml.ReadElementContentAsString(); if (type == ProjectItem) { item = ProjectHandler.ReadFrom(xml, config); } Debug.Assert(item != null); item.Id = new Guid(id); item.DisplayName = displayName; item.RelativePath = relativePath; vCase.Items.Add(item); } } } return vCase; }
public static VCase ReadFrom(string filePath, IProjectConfiguration config) { var vCase = new VCase(); using (var stream = new StreamReader(filePath, Encoding.UTF8)) using (var xml = new XmlTextReader(stream)) { xml.ReadToFollowing("Case"); if (xml.ReadToFollowing("Name")) { vCase.Name = xml.ReadElementContentAsString(); } if (xml.ReadToFollowing("CaseItems")) { while (xml.ReadToFollowing("CaseItem")) { VCaseItem item = null; xml.ReadToFollowing("Id"); var id = xml.ReadElementContentAsString(); xml.ReadToFollowing("DisplayName"); var displayName = xml.ReadElementContentAsString(); xml.ReadToFollowing("RelativePath"); var relativePath = xml.ReadElementContentAsString(); xml.ReadToFollowing("Type"); var type = xml.ReadElementContentAsString(); if (type == ProjectItem) { item = ProjectHandler.ReadFrom(xml, config); } Debug.Assert(item != null); item.Id = new Guid(id); item.DisplayName = displayName; item.RelativePath = relativePath; vCase.Items.Add(item); } } } return(vCase); }
private void WritePackageFabric(IProjectConfiguration config) { var fabric = config as FabricApplicationProjectConfiguration; if (fabric == null) { return; } using (Tag("msbuild")) { Tag("executable", "$(msbuildExecutable)"); Tag("targets", "Package"); Tag("workingDirectory", fabric.SourceDirectory()); Tag("buildArgs", "/noconsolelogger /p:Configuration=Release"); Tag("description", "Package fabric application"); } }
private void WriteSourceControl(IProjectConfiguration config) { using (Tag("sourcecontrol")) { Attr("type", "multi"); using (Tag("sourceControls")) { var tfs = config as ITfsControl; if (tfs != null) { using (Tag("vsts")) { Tag("executable", "$(tfsExecutable)"); Tag("server", "$(tfsUrl)"); Tag("project", tfs.TfsPath); Tag("workingDirectory", tfs.SourceDirectory()); Tag("applyLabel", "false"); Tag("autoGetSource", "true"); Tag("cleanCopy", "true"); Tag("workspace", $"CCNET_{tfs.Server}_{GetQueue(config)}"); Tag("deleteWorkspace", "true"); } } var references = config as IReferencesDirectory; if (references != null) { using (Tag("filesystem")) { Tag("repositoryRoot", references.ReferencesDirectory()); Tag("autoGetSource", "false"); Tag("ignoreMissingRoot", "true"); } } using (Tag("filesystem")) { Tag("repositoryRoot", config.AdminDirectoryRebuildAll()); Tag("autoGetSource", "false"); Tag("ignoreMissingRoot", "true"); } } } }
private void WritePublishers(IProjectConfiguration config) { using (Tag("publishers")) { using (Tag("modificationHistory")) { Attr("onlyLogWhenChangesFound", "true"); } Tag("xmllogger", null); Tag("statistics", null); using (Tag("artifactcleanup")) { Attr("cleanUpMethod", "KeepLastXBuilds"); Attr("cleanUpValue", "100"); } using (Tag("artifactcleanup")) { Attr("cleanUpMethod", "KeepMaximumXHistoryDataEntries"); Attr("cleanUpValue", "100"); } if (!String.IsNullOrEmpty(config.OwnerEmail)) { using (CbTag("EmailPublisher")) { Attr("mailto", config.OwnerEmail); } } //xxx if (config.Name == "Metro.Portal.Web") { return; } using (CbTag("DeleteDirectory")) { Attr("path", config.WorkingDirectory()); } } }
public static IEnumerable <FilePath> GetSrcProjectArtifacts( this IProjectConfiguration config) { if (config == null) { throw new ArgumentNullException(nameof(config)); } return(config.SrcProjects .SelectMany(t => { var outputDirString = t.GetProjectBinOutputDirectoryPath(config); var filePaths = t.GetProjectOutputFileNamePatterns() .Select(x => $"{outputDirString}/{x}") .SelectMany(x => config.Context.GetFiles(x)); return filePaths; }) .Where(t => config.Context.FileExists(t))); }
/// <summary> /// Commits any pending changes and builds a fake IProject instance. /// </summary> /// <returns>A fake IProject instance consisting of the previously registered output, definitions and sources</returns> public IProject Build() { IProject fake = A.Fake <IProject>(); A.CallTo(() => fake.Name).Returns(this._name); IProjectConfiguration fakeConfiguration = A.Fake <IProjectConfiguration>(); A.CallTo(() => fakeConfiguration.PrimaryOutput).Returns(this._primaryOutput); A.CallTo(() => fake.ActiveConfiguration).Returns(fakeConfiguration); IVSDebugConfiguration fakeVSConfiguration = A.Fake <IVSDebugConfiguration>(); A.CallTo(() => fakeVSConfiguration.WorkingDirectory).Returns(this._workingDirectory); A.CallTo(() => fakeVSConfiguration.Environment).Returns(this._environment); A.CallTo(() => fakeConfiguration.VSDebugConfiguration).Returns(fakeVSConfiguration); return(fake); }
/// <inheritdoc /> public IProject?Construct(IProjectConfiguration config) { LogTo.Debug($"Trying to construct project from {config.BuildConnectionName} and {config.SourceControlConnectionName}"); var buildProvider = BuildProvider(config.BuildConnectionName); if (buildProvider == null) { LogTo.Error("Failed to construct build provider"); return(null); } var branchProvider = BranchProvider(config.SourceControlConnectionName); if (branchProvider == null) { LogTo.Error("Failed to construct branch provider"); return(null); } return(new Project(buildProvider, branchProvider, config)); }
public static VProject ReadFrom(XmlTextReader xml, IProjectConfiguration config) { var project = new VProject(); if (xml.ReadToFollowing("Code")) { var code = xml.ReadElementContentAsString(); project.ProjectDescriptor = config.GetDescriptor(code); } if (xml.ReadToFollowing("ProjectItems")) { while (xml.ReadToFollowing("ProjectItem")) { xml.ReadToFollowing("Name"); var name = xml.ReadElementContentAsString(); xml.ReadToFollowing("Code"); var c = xml.ReadElementContentAsString(); project.Items.Add(new VProjectItem(config.GetItemDescriptor(c), name)); } } return project; }
private void WriteProjectHeader(IProjectConfiguration config) { Tag("name", config.UniqueName()); Tag("description", config.Description); Tag("category", GetCategory(config)); Tag("queue", GetQueue(config)); Tag("workingDirectory", config.ProjectDirectory()); Tag("artifactDirectory", config.ProjectDirectory()); using (Tag("state")) { Attr("type", "state"); Attr("directory", config.ProjectDirectory()); } Tag("webURL", config.WebUrl()); using (Tag("labeller")) { Attr("type", "shortDateLabeller"); } }
private void WritePrepareProject(IProjectConfiguration config) { var prepare = config as IPrepareProject; if (prepare == null) return; var args = new List<Arg> { new Arg("path", prepare.SourceDirectory()), new Arg("version", "$[$CCNetLabel]"), new Arg("tfs", prepare.TfsPath), new Arg("output", prepare.TempDirectory()) }; if (prepare.ProjectExtension == "csproj") { args.Add(new Arg("updateAssemblyInfo", "true")); } ExecTask( "$(ccnetBuildPrepareProject)", "Prepare project", args.ToArray()); }
private void WriteCheckProject(IProjectConfiguration config) { var check = config as ICheckProject; if (check == null) return; var args = new List<Arg> { new Arg("name", check.Name), new Arg("local", check.SourceDirectory()), new Arg("remote", check.TfsPath), new Arg("extension", check.ProjectExtension) }; /*var company = "CNET Content Solutions"; var assembly = config as IAssembly; if (assembly != null) { if (assembly.RootNamespace != null) args.Add(new Arg("RootNamespace", assembly.RootNamespace)); if (assembly.CustomAssemblyName != null) args.Add(new Arg("AssemblyName", assembly.CustomAssemblyName)); if (assembly.CustomCompanyName != null) company = assembly.CustomCompanyName; } args.Add(new Arg("CompanyName", company));*/ var issues = new List<string>(); issues.Add(F01_ProjectFileShouldExist); issues.Add(F02_AssemblyInfoShouldExist); issues.Add(S01_ProjectFolderShouldHaveProjectName); issues.Add(S02_PrimarySolutionShouldExist); //xxxissues.Add(S03_NugetFolderShouldNotExist); issues.Add(S04_PackagesFolderShouldNotExist); if (config is FabricApplicationProjectConfiguration) { issues.Remove(F02_AssemblyInfoShouldExist); } if (!String.IsNullOrWhiteSpace(check.CustomIssues)) { var all = check.CustomIssues.Split('|'); var force = all.Where(code => code.StartsWith("+")).Select(code => code.Substring(1)).ToList(); var ignore = all.Where(code => code.StartsWith("-")).Select(code => code.Substring(1)).ToList(); issues = issues.Union(force).Except(ignore).ToList(); } args.Add(new Arg("issues", String.Join("|", issues))); ExecTask( "$(netBuildCheckProject)", "Check project", args.ToArray()); }
private void WritePublishRelease(IProjectConfiguration config) { var release = config as IPublishRelease; if (release == null) return; using (CbTag("CopyFiles")) { Attr("from", $@"{release.SourceDirectoryRelease()}\*"); Attr("to", release.TempDirectoryPublish()); } using (CbTag("EraseXmlDocs")) { Attr("path", release.TempDirectoryPublish()); } using (CbTag("EraseConfigFiles")) { Attr("path", release.TempDirectoryPublish()); } }
private void WriteXxx(IProjectConfiguration config) { var xxx = config as FabricServiceProjectConfiguration; if (xxx == null) return; if (xxx.Name == "Metro.Portal.Web") { using (Tag("exec")) { Tag("executable", @"C:\Program Files\nodejs\npm.cmd"); Tag("buildTimeoutSeconds", "180"); Tag("buildArgs", "install"); Tag("baseDirectory", xxx.SourceDirectory()); Tag("description", "XXX npm"); } using (Tag("msbuild")) { Tag("executable", "$(msbuildExecutable)"); Tag("targets", "Build"); Tag("workingDirectory", xxx.SourceDirectory()); Tag("buildArgs", "/noconsolelogger /p:Configuration=Release"); Tag("description", "Build XXX project"); } } }
private void WritePublishFabric(IProjectConfiguration config) { var fabric = config as FabricApplicationProjectConfiguration; if (fabric == null) return; using (CbTag("CopyFiles")) { Attr("from", $@"{fabric.SourceDirectoryPackage()}\*"); Attr("to", fabric.TempDirectoryPublish()); } }
private void WritePackageFabric(IProjectConfiguration config) { var fabric = config as FabricApplicationProjectConfiguration; if (fabric == null) return; using (Tag("msbuild")) { Tag("executable", "$(msbuildExecutable)"); Tag("targets", "Package"); Tag("workingDirectory", fabric.SourceDirectory()); Tag("buildArgs", "/noconsolelogger /p:Configuration=Release"); Tag("description", "Package fabric application"); } }
private void WritePrebuild(IProjectConfiguration config) { using (Tag("prebuild")) { //xxx if (config.Name == "Metro.Portal.Web") { using (CbTag("PurgeDirectory")) { Attr("path", config.WorkingDirectory() + @"\source"); } } using (CbTag("DeleteDirectory")) { Attr("path", config.WorkingDirectory()); } var temp = config as ITempDirectory; if (temp != null) { using (CbTag("CreateDirectory")) { Attr("path", temp.TempDirectory()); } } var related = config as IRelatedDirectory; if (related != null) { using (CbTag("CreateDirectory")) { Attr("path", related.RelatedDirectory()); } } } }
private static string GetQueue(IProjectConfiguration config) { return config.Area; }
private void WritePublishers(IProjectConfiguration config) { using (Tag("publishers")) { using (Tag("modificationHistory")) { Attr("onlyLogWhenChangesFound", "true"); } Tag("xmllogger", null); Tag("statistics", null); using (Tag("artifactcleanup")) { Attr("cleanUpMethod", "KeepLastXBuilds"); Attr("cleanUpValue", "100"); } using (Tag("artifactcleanup")) { Attr("cleanUpMethod", "KeepMaximumXHistoryDataEntries"); Attr("cleanUpValue", "100"); } if (!String.IsNullOrEmpty(config.OwnerEmail)) { using (CbTag("EmailPublisher")) { Attr("mailto", config.OwnerEmail); } } //xxx if (config.Name == "Metro.Portal.Web") return; using (CbTag("DeleteDirectory")) { Attr("path", config.WorkingDirectory()); } } }
private void WriteNotifyProjects(IProjectConfiguration config) { var notify = config as INotifyProjects; if (notify == null) return; ExecTaskLegacy( "$(ccnetBuildNotifyProjects)", "Notify other projects", new Arg("ProjectName", config.Name), new Arg("BuildPath", "$(buildPath)"), new Arg("ServerNames", "Library|Website|Service|Application|Azure"), new Arg("ReferencesFolder", "references")); }
private void WriteSaveSnapshot(IProjectConfiguration config) { var snapshot = config as ISaveSnapshot; if (snapshot == null) return; using (CbTag("AppendToFile")) { Attr("file", snapshot.TempFileExcludeFromSnapshot()); Attr("text", "$tf"); } using (CbTag("AppendToFile")) { Attr("file", snapshot.TempFileExcludeFromSnapshot()); Attr("text", "*.nupkg"); } var source = config as ISourceDirectory; if (source != null) { using (CbTag("CompressDirectoryExclude")) { Attr("path", source.SourceDirectory()); Attr("output", snapshot.SnapshotSourceFile()); Attr("exclude", snapshot.TempFileExcludeFromSnapshot()); } AzureUpload(config, "snapshot", snapshot.SnapshotSourceFile()); } var packages = config as IPackagesDirectory; if (packages != null) { using (CbTag("CompressDirectoryExclude")) { Attr("path", packages.PackagesDirectory()); Attr("output", snapshot.SnapshotPackagesFile()); Attr("exclude", snapshot.TempFileExcludeFromSnapshot()); } AzureUpload(config, "snapshot", snapshot.SnapshotPackagesFile()); } }
private void WritePublishCompressed(IProjectConfiguration config) { var compressed = config as IPublishCompressed; if (compressed == null) return; if (compressed.ExcludeFromPublish != null) { foreach (var exclude in compressed.ExcludeFromPublish.Split('|')) { using (CbTag("AppendToFile")) { Attr("file", compressed.TempFileExcludeFromPublish()); Attr("text", exclude); } } using (CbTag("CompressDirectoryExclude")) { Attr("path", compressed.TempDirectoryPublish()); Attr("output", compressed.PublishReleaseFile()); Attr("exclude", compressed.TempFileExcludeFromPublish()); } } else { using (CbTag("CompressDirectory")) { Attr("path", compressed.TempDirectoryPublish()); Attr("output", compressed.PublishReleaseFile()); } } AzureUpload(config, "publish", compressed.PublishReleaseFile()); }
private void WriteTasks(IProjectConfiguration config) { using (Tag("tasks")) { WriteCheckProject(config); WritePrepareProject(config); WriteCustomReport(config); WriteXxx(config); WriteSetupPackages(config); WriteBuildAssembly(config); WritePackageFabric(config); WritePublishRelease(config); WritePublishFabric(config); WritePublishCompressed(config); WriteSaveSnapshot(config); WriteCompleteBuild(config); WriteNotifyProjects(config); } }
private void WriteCustomReport(IProjectConfiguration config) { var report = config as ICustomReport; if (report == null) return; var args = new List<Arg> { new Arg("confluence", report.ConfluencePage) }; var nuget = config as INugetPackage; if (nuget != null) { args.Add(new Arg("nuget", nuget.UniqueName())); } ExecTask( "$(ccnetBuildCustomReport)", "Report custom output", args.ToArray()); }
private void WriteTriggers(IProjectConfiguration config) { using (Tag("triggers")) { using (Tag("intervalTrigger")) { Attr("buildCondition", "IfModificationExists"); Tag("seconds", config.CheckEvery.TotalSeconds.ToString()); Tag("initialSeconds", "15"); } using (Tag("scheduleTrigger")) { Attr("buildCondition", "ForceBuild"); Tag("time", "23:00"); Tag("randomOffSetInMinutesFromTime", "45"); using (Tag("weekDays")) { Tag("weekDay", "Saturday"); } } } }
private static string GetCategory(IProjectConfiguration config) { return config.Area; }
private void WriteSetupPackages(IProjectConfiguration config) { var setup = config as ISetupPackages; if (setup == null) return; //xxx working on xproj here if (setup.ProjectExtension == "xproj") return; var args = new List<Arg> { new Arg("ProjectFile", setup.ProjectFilePath()), new Arg("PackagesPath", setup.PackagesDirectory()), new Arg("ReferencesPath", setup.ReferencesDirectory()), new Arg("TempPath", setup.TempDirectory()), new Arg("NuGetExecutable", "$(nugetExecutable)"), new Arg("NuGetUrl", setup.NugetRestoreUrl()) }; var related = config as IResolveRelated; if (related != null) args.Add(new Arg("RelatedPath", related.RelatedDirectory())); if (setup.CustomVersions != null) args.Add(new Arg("CustomVersions", setup.CustomVersions)); var bundle = config as IMakeBundle; if (bundle != null) { args.Add(new Arg("Bundles", bundle.Bundles)); } var nuget = config as INugetPackage; if (nuget != null) { args.Add(new Arg("Dependencies", nuget.Dependencies)); } ExecTaskLegacy( "$(ccnetBuildSetupPackages)", "Setup packages", args.ToArray()); }
public ConfigCheckOutWrapper(IProjectConfiguration config, string path, ISourceControl sourceControl) { _config = config; _path = path; _sourceControl = sourceControl; }
private void WriteBuildAssembly(IProjectConfiguration config) { var build = config as IBuildAssembly; if (build == null) return; //xxx working on xproj here if (config is IProjectFile) { if (((IProjectFile)config).ProjectExtension == "xproj") return; } using (Tag("msbuild")) { Tag("executable", "$(msbuildExecutable)"); Tag("targets", "Build"); Tag("workingDirectory", build.SourceDirectory()); Tag("buildArgs", "/noconsolelogger /p:Configuration=Release"); Tag("description", "Build project"); } }