public async Task Pack_project_blazor_contents() { var asset = await Create.NetstandardWorkspaceCopy(); var packageName = Path.GetFileNameWithoutExtension(asset.Directory.GetFiles("*.csproj").First().Name); var console = new TestConsole(); await PackCommand.Do(new PackOptions(asset.Directory, enableWasm : true), console); asset.Directory .GetFiles() .Should() .Contain(f => f.Name.Contains("nupkg")); var dotnet = new Dotnet(asset.Directory); var result = await dotnet.ToolInstall(packageName, asset.Directory, new PackageSource(asset.Directory.FullName)); var exe = Path.Combine(asset.Directory.FullName, packageName); var tool = WorkspaceServer.WorkspaceFeatures.PackageTool.TryCreateFromDirectory(packageName, new FileSystemDirectoryAccessor(asset.Directory)); await tool.Prepare(); var wasmDirectory = await tool.LocateWasmAsset(); wasmDirectory.Should().NotBeNull(); }
public async Task Pack_project_blazor_contents() { var asset = await Create.NetstandardWorkspaceCopy(); var packageName = Path.GetFileNameWithoutExtension(asset.Directory.GetFiles("*.csproj").First().Name); var console = new TestConsole(); await PackCommand.Do(new PackOptions(asset.Directory, enableBlazor : true), console); asset.Directory .GetFiles() .Should() .Contain(f => f.Name.Contains("nupkg")); var dotnet = new Dotnet(asset.Directory); var result = await dotnet.ToolInstall(packageName, asset.Directory, asset.Directory); var exe = Path.Combine(asset.Directory.FullName, packageName); var tool = new WorkspaceServer.WorkspaceFeatures.PackageTool(packageName, asset.Directory); await tool.Prepare(); var projectDirectory = await tool.LocateProjects(); var subDirectories = projectDirectory.GetDirectories(); subDirectories.Should().Contain(d => d.Name == "packTarget"); subDirectories.Should().Contain(d => d.Name == $"runner-{packageName}"); }
public static async Task <(DirectoryInfo, string)> CreateTool(TestConsole console) { var asset = await Create.NetstandardWorkspaceCopy(); await PackCommand.Do(new PackOptions(asset.Directory), console); return(asset.Directory, asset.Name); }
public async Task Pack_project_works_with_blazor() { var asset = await Create.NetstandardWorkspaceCopy(); var console = new TestConsole(); await PackCommand.Do(new PackOptions(asset.Directory, enableBlazor : true), console); asset.Directory .GetFiles() .Should() .Contain(f => f.Name.Contains("nupkg")); }
public async Task Pack_project_creates_a_nupkg_with_passed_version() { var asset = await Create.NetstandardWorkspaceCopy(); var console = new TestConsole(); await PackCommand.Do(new PackOptions(asset.Directory, "3.4.5"), console); asset.Directory .GetFiles() .Should() .Contain(f => f.Name.Contains("3.4.5.nupkg")); }
public static async Task <(string packageName, DirectoryInfo addSource)> NupkgWithBlazorEnabled([CallerMemberName] string testName = null) { DirectoryInfo destination = new DirectoryInfo( Path.Combine(Package.DefaultPackagesDirectory.FullName, "nupkgs")); var asset = await NetstandardWorkspaceCopy(testName, destination); var packageName = asset.Directory.Name; var console = new TestConsole(); await PackCommand.Do(new PackOptions(asset.Directory, enableBlazor : true, packageName : packageName), console); var nupkg = asset.Directory.GetFiles("*.nupkg").Single(); return(packageName, nupkg.Directory); }
private async Task <(string packageName, DirectoryInfo packageLocation)> CreateLocalTool(IConsole console) { // Keep project name short to work around max path issues var projectName = Guid.NewGuid().ToString("N").Substring(0, 8); var build = await Create.NewPackage(projectName, Create.ConsoleConfiguration) as IHaveADirectory; var ws = await((ICreateWorkspaceForRun)build).CreateRoslynWorkspaceForRunAsync(new TimeBudget(30.Seconds())); var packageLocation = new DirectoryInfo( Path.Combine(build.Directory.FullName, "pack-output")); var packageName = await PackCommand.Do( new PackOptions( build.Directory, outputDirectory : packageLocation, enableBlazor : false), console); return(packageName, packageLocation); }
public async Task Discover_tool_from_directory() { using (var directory = DisposableDirectory.Create()) { var console = new TestConsole(); var temp = directory.Directory; var asset = (await Create.ConsoleWorkspaceCopy()).Directory; await PackCommand.Do(new PackOptions(asset, outputDirectory : temp, enableWasm : false), console); var result = await Tools.CommandLine.Execute("dotnet", $"tool install --add-source {temp.FullName} console --tool-path {temp.FullName}"); output.WriteLine(string.Join("\n", result.Error)); result.ExitCode.Should().Be(0); var strategy = new LocalToolInstallingPackageDiscoveryStrategy(temp); var tool = await strategy.Locate(new PackageDescriptor("console")); tool.Should().NotBeNull(); } }
public async Task Discover_tool_from_directory() { using (var directory = DisposableDirectory.Create()) { var console = new TestConsole(); var temp = directory.Directory; var package = await Create.ConsoleWorkspaceCopy(); File.Move(package.Directory.GetFiles("*.csproj").First().FullName, Path.Combine(package.Directory.FullName, "not-console.csproj")); await PackCommand.Do(new PackOptions(package.Directory, outputDirectory : temp, enableWasm : false), console); var result = await Microsoft.DotNet.Interactive.Utility.CommandLine.Execute("dotnet", $"tool install --add-source {temp.FullName} not-console --tool-path {temp.FullName}"); output.WriteLine(string.Join("\n", result.Error)); result.ExitCode.Should().Be(0); var strategy = new LocalToolInstallingPackageDiscoveryStrategy(temp); var tool = await strategy.Locate(new PackageDescriptor("not-console")); tool.Should().NotBeNull(); } }
private async Task <(string packageName, DirectoryInfo addSource)> CreateLocalTool(IConsole console) { // Keep project name short to work around max path issues var projectName = Guid.NewGuid().ToString("N").Substring(0, 8); var copy = Create.EmptyWorkspace( initializer: new PackageInitializer( "console", projectName)); await copy.CreateRoslynWorkspaceForRunAsync(new Budget()); var packageLocation = new DirectoryInfo( Path.Combine(copy.Directory.FullName, "pack-output")); var packageName = await PackCommand.Do( new PackOptions( copy.Directory, outputDirectory : packageLocation, enableBlazor : false), console); return(packageName, packageLocation); }