ConsoleDebugTargetsProvider GetDebugTargetsProvider(string outputType = "exe", Dictionary <string, string> properties = null) { _mockFS.WriteAllText(@"c:\test\Project\someapp.exe", ""); _mockFS.CreateDirectory(@"c:\test\Project"); _mockFS.WriteAllText(@"c:\program files\dotnet\dotnet.exe", ""); LaunchProfile activeProfile = new LaunchProfile() { Name = "MyApplication", CommandLineArgs = "--someArgs", ExecutablePath = @"c:\test\Project\someapp.exe" }; _mockEnvironment.Setup(s => s.GetEnvironmentVariable("Path")).Returns(() => _Path); var project = IUnconfiguredProjectFactory.Create(null, null, _ProjectFile); var outputTypeEnum = new PageEnumValue(new EnumValue() { Name = outputType }); var data = new PropertyPageData() { Category = ConfigurationGeneral.SchemaName, PropertyName = ConfigurationGeneral.OutputTypeProperty, Value = outputTypeEnum }; var projectProperties = ProjectPropertiesFactory.Create(project, data); if (properties == null) { properties = new Dictionary <string, string>() { { "TargetPath", @"c:\test\project\bin\project.dll" }, { "TargetFrameworkIdentifier", @".NetCoreApp" } }; } var delegatePropertiesMock = IProjectPropertiesFactory .MockWithPropertiesAndValues(properties); var delegateProvider = IProjectPropertiesProviderFactory.Create(null, delegatePropertiesMock.Object); IConfiguredProjectServices configuredProjectServices = Mock.Of <IConfiguredProjectServices>(o => o.ProjectPropertiesProvider == delegateProvider); ConfiguredProject configuredProject = Mock.Of <ConfiguredProject>(o => o.UnconfiguredProject == project && o.Services == configuredProjectServices); _mockTokenReplace.Setup(s => s.ReplaceTokensInProfileAsync(It.IsAny <ILaunchProfile>())).Returns <ILaunchProfile>(p => Task.FromResult(p)); var debugProvider = new ConsoleDebugTargetsProvider( configuredProject, _mockTokenReplace.Object, _mockFS, _mockEnvironment.Object, projectProperties); return(debugProvider); }
private IFileSystem CreateFileSystem(bool withEntries = true) { var fileSystem = new IFileSystemMock(); if (withEntries) { fileSystem.CreateDirectory(RootLocation); fileSystem.CreateDirectory(BackupLocation); fileSystem.Create(XprojLocation); fileSystem.Create(ProjectJsonLocation); } return(fileSystem); }
private IFileSystem CreateFileSystem(bool withEntries = true, MigrationReport report = null, bool withXprojUser = false, bool withProjectLock = false, bool withGlobalJson = false) { var fileSystem = new IFileSystemMock(); if (withEntries) { fileSystem.CreateDirectory(RootLocation); fileSystem.CreateDirectory(BackupLocation); fileSystem.Create(XprojLocation); fileSystem.Create(ProjectJsonLocation); if (withXprojUser) { fileSystem.Create(XprojUserLocation); } if (withProjectLock) { fileSystem.Create(ProjectLockJsonLocation); } if (withGlobalJson) { fileSystem.WriteAllText(GlobalJsonLocation, JsonConvert.SerializeObject(new object())); } } fileSystem.SetTempFile(LogFileLocation); if (withEntries) { report = report ?? new MigrationReport(1, new List <ProjectMigrationReport>() { new ProjectMigrationReport(true, CsprojLocation, RootLocation, ProjectName, new List <string>(), new List <MigrationError>()) }); fileSystem.WriteAllText(LogFileLocation, JsonConvert.SerializeObject(report)); } return(fileSystem); }
private ConsoleDebugTargetsProvider GetDebugTargetsProvider(string outputType = "exe", Dictionary <string, string> properties = null) { _mockFS.WriteAllText(@"c:\test\Project\someapp.exe", ""); _mockFS.CreateDirectory(@"c:\test\Project"); _mockFS.CreateDirectory(@"c:\test\Project\bin\"); _mockFS.WriteAllText(@"c:\program files\dotnet\dotnet.exe", ""); _mockEnvironment.Setup(s => s.GetEnvironmentVariable("Path")).Returns(() => _Path); var project = UnconfiguredProjectFactory.Create(filePath: _ProjectFile); var outputTypeEnum = new PageEnumValue(new EnumValue() { Name = outputType }); var data = new PropertyPageData() { Category = ConfigurationGeneral.SchemaName, PropertyName = ConfigurationGeneral.OutputTypeProperty, Value = outputTypeEnum }; var projectProperties = ProjectPropertiesFactory.Create(project, data); if (properties == null) { properties = new Dictionary <string, string>() { { "RunCommand", @"dotnet" }, { "RunArguments", "exec " + "\"" + @"c:\test\project\bin\project.dll" + "\"" }, { "RunWorkingDirectory", @"bin\" }, { "TargetFrameworkIdentifier", @".NetCoreApp" }, { "OutDir", @"c:\test\project\bin\" } }; } var delegatePropertiesMock = IProjectPropertiesFactory .MockWithPropertiesAndValues(properties); var delegateProvider = IProjectPropertiesProviderFactory.Create(null, delegatePropertiesMock.Object); var configuredProjectServices = Mock.Of <IConfiguredProjectServices>(o => o.ProjectPropertiesProvider == delegateProvider); var configuredProject = Mock.Of <ConfiguredProject>(o => o.UnconfiguredProject == project && o.Services == configuredProjectServices); _mockTokenReplace.Setup(s => s.ReplaceTokensInProfileAsync(It.IsAny <ILaunchProfile>())).Returns <ILaunchProfile>(p => Task.FromResult(p)); var activeDebugFramework = Mock.Of <IActiveDebugFrameworkServices>(o => o.GetConfiguredProjectForActiveFrameworkAsync() == Task.FromResult(configuredProject)); var debugProvider = new ConsoleDebugTargetsProvider( configuredProject, _mockTokenReplace.Object, _mockFS, _mockEnvironment.Object, activeDebugFramework, projectProperties); return(debugProvider); }
public async Task QueryDebugTargetsAsync_ProjectProfileAsyncF5() { var debugger = GetDebugTargetsProvider(); _mockFS.WriteAllText(@"c:\program files\dotnet\dotnet.exe", ""); _mockFS.CreateDirectory(@"c:\test\project"); var activeProfile = new LaunchProfile() { Name = "MyApplication", CommandName = "Project", CommandLineArgs = "--someArgs" }; var targets = await debugger.QueryDebugTargetsAsync(0, activeProfile); Assert.Single(targets); Assert.Equal(@"c:\program files\dotnet\dotnet.exe", targets[0].Executable); Assert.Equal(DebugLaunchOperation.CreateProcess, targets[0].LaunchOperation); Assert.Equal(DebuggerEngines.ManagedCoreEngine, targets[0].LaunchDebugEngineGuid); Assert.Equal(0, targets[0].AdditionalDebugEngines.Count); Assert.Equal("exec \"c:\\test\\project\\bin\\project.dll\" --someArgs", targets[0].Arguments); }