public static void TargetCleanOutput(ITaskContext context) { string buildConfiguration = context.Properties.Get <string>(BuildProps.BuildConfiguration); string productRootDir = context.Properties.Get(BuildProps.ProductRootDir, "."); VSSolution solution = context.Properties.Get <VSSolution>(BuildProps.Solution); solution.ForEachProject( delegate(VSProjectInfo projectInfo) { if (projectInfo is VSProjectWithFileInfo) { VSProjectWithFileInfo info = (VSProjectWithFileInfo)projectInfo; LocalPath projectOutputPath = info.GetProjectOutputPath(buildConfiguration); if (projectOutputPath == null) { return; } FullPath projectFullOutputPath = info.ProjectDirectoryPath.CombineWith(projectOutputPath); DeleteDirectoryTask.Execute(context, projectFullOutputPath.ToString(), false); string projectObjPath = String.Format( CultureInfo.InvariantCulture, @"{0}\obj\{1}", projectInfo.ProjectName, buildConfiguration); projectObjPath = Path.Combine(productRootDir, projectObjPath); DeleteDirectoryTask.Execute(context, projectObjPath, false); } }); }
public static FullPath GetProjectOutputPath(this ITaskContext context, string projectName) { VSSolution solution = context.Properties.Get <VSSolution>(BuildProps.Solution); VSProjectWithFileInfo projectInfo = (VSProjectWithFileInfo)solution.FindProjectByName(projectName); LocalPath projectOutputPath = projectInfo.GetProjectOutputPath( context.Properties.Get <string>(BuildProps.BuildConfiguration)); FullPath projectTargetDir = projectInfo.ProjectDirectoryPath.CombineWith(projectOutputPath); return(projectTargetDir); }
private static void TargetPackage(ITaskContext context) { FullPath packagesDir = new FullPath(context.Properties.Get(BuildProps.ProductRootDir, ".")); packagesDir = packagesDir.CombineWith(context.Properties.Get <string>(BuildProps.BuildDir)); FullPath simplexPackageDir = packagesDir.CombineWith("Detergent"); FileFullPath zipFileName = packagesDir.AddFileName( "Detergent-{0}.zip", context.Properties.Get <Version>(BuildProps.BuildVersion)); StandardPackageDef packageDef = new StandardPackageDef("Detergent", context); VSSolution solution = context.Properties.Get <VSSolution>(BuildProps.Solution); VSProjectWithFileInfo projectInfo = (VSProjectWithFileInfo)solution.FindProjectByName("Detergent"); LocalPath projectOutputPath = projectInfo.GetProjectOutputPath( context.Properties.Get <string>(BuildProps.BuildConfiguration)); FullPath projectTargetDir = projectInfo.ProjectDirectoryPath.CombineWith(projectOutputPath); packageDef.AddFolderSource( "bin", projectTargetDir, false); ICopier copier = new Copier(context); CopyProcessor copyProcessor = new CopyProcessor( context, copier, simplexPackageDir); copyProcessor .AddTransformation("bin", new LocalPath(string.Empty)); IPackageDef copiedPackageDef = copyProcessor.Process(packageDef); Zipper zipper = new Zipper(context); ZipProcessor zipProcessor = new ZipProcessor( context, zipper, zipFileName, simplexPackageDir, null, "bin"); zipProcessor.Process(copiedPackageDef); }
public static void TargetRunTestsNUnit( ITaskContext context, string projectName) { VSSolution solution = context.Properties.Get <VSSolution>(BuildProps.Solution); string buildConfiguration = context.Properties.Get <string>(BuildProps.BuildConfiguration); VSProjectWithFileInfo project = (VSProjectWithFileInfo)solution.FindProjectByName(projectName); FileFullPath projectTarget = project.ProjectDirectoryPath.CombineWith(project.GetProjectOutputPath(buildConfiguration)) .AddFileName("{0}.dll", project.ProjectName); IRunProgramTask task = new RunProgramTask( context.Properties[BuildProps.NUnitConsolePath]) .AddArgument(projectTarget.ToString()) .AddArgument("/labels") .AddArgument("/trace=Verbose") .AddArgument("/nodots") .AddArgument("/noshadow"); task.Execute(context); }
private void SetAssemblyFileNameAndWorkingDirFromProjectName(ITaskContext context) { if (projectName != null) { VSSolution solution = context.Properties.Get <VSSolution>(BuildProps.Solution); string buildConfiguration = context.Properties.Get <string>(BuildProps.BuildConfiguration); VSProjectWithFileInfo project = (VSProjectWithFileInfo)solution.FindProjectByName(projectName); FileFullPath projectTarget = project.ProjectDirectoryPath.CombineWith(project.GetProjectOutputPath(buildConfiguration)) .AddFileName("{0}.dll", project.ProjectName); testAssemblyFileName = projectTarget.ToString(); workingDirectory = Path.GetDirectoryName(projectTarget.ToString()); } }