public void BeforeAll() { _projectFilePath = @"C:\myproject\myproject.csproj"; _projectDirectory = @"C:\myproject"; _projectName = "What I am called"; _dependencies = Builder <NuGetPackageDependency> .CreateListOfSize(2).Build(); _expectedPackageFilePath = @"C:\myproject\packages.config"; var fileSystem = new Mock <IFileSystem>(); fileSystem.Setup(fs => fs.GetDirectory(_projectFilePath)).Returns(_projectDirectory); var packageBuilder = new Mock <IBuilder <ICollection <NuGetPackageDependency>, string> >(); packageBuilder.Setup(b => b.Build(_expectedPackageFilePath)).Returns(_dependencies); var builder = new ProjectBuilder(fileSystem.Object, packageBuilder.Object); var request = new BuildProjectRequest() .WithProjectFilePath(_projectFilePath) .WithName(_projectName); _project = builder.Build(request); }
BuildProjectResponse HandleBuildProjectRequest(BuildProjectRequest req) { var targetsPath = typeof(AvaloniaIdeTask).GetTypeInfo().Assembly.GetModules()[0].FullyQualifiedName; targetsPath = Path.Combine(Path.GetDirectoryName(targetsPath), "avalonia-ide.targets"); var props = new Dictionary <string, string> { ["DesignTimeBuild"] = "false", ["BuildProjectReferences"] = "false", ["_ResolveReferenceDependencies"] = "true", ["SolutionDir"] = req.SolutionDirectory, ["ProvideCommandLineInvocation"] = "false", ["SkipCompilerExecution"] = "false", ["BuildProjectReferences"] = "false", ["TargetFramework"] = req.TargetFramework, ["CustomBeforeMicrosoftCommonTargets"] = targetsPath }; var outputs = new Dictionary <string, ITaskItem[]>(); var status = BuildEngine.BuildProjectFile(req.FullPath, null, props, outputs); var result = new BuildProjectResponse { Success = status }; if (!status) { } if (outputs.ContainsKey("Build")) { result.OutputAssemblies = outputs["Build"].Select(item => item.ItemSpec).ToList(); } return(result); }