public void GivenNugetConfigAndPackageNameAndVersionAndTargetFrameworkWhenCallItCreateAssetFile() { var nugetConfigPath = WriteNugetConfigFileToPointToTheFeed(); var toolsPath = Path.Combine(Directory.GetCurrentDirectory(), Path.GetRandomFileName()); var packageObtainer = ConstructDefaultPackageObtainer(toolsPath); ToolConfigurationAndExecutableDirectory toolConfigurationAndExecutableDirectory = packageObtainer.ObtainAndReturnExecutablePath( packageId: TestPackageId, packageVersion: TestPackageVersion, nugetconfig: nugetConfigPath, targetframework: _testTargetframework); var assetJsonPath = toolConfigurationAndExecutableDirectory .ExecutableDirectory .GetParentPath() .GetParentPath() .GetParentPath() .GetParentPath() .GetParentPath() .WithFile("project.assets.json").Value; File.Exists(assetJsonPath) .Should() .BeTrue(assetJsonPath + " should be created"); }
public void GivenAllButNoTargetFrameworkItCanDownloadThePackage() { var nugetConfigPath = WriteNugetConfigFileToPointToTheFeed(); var toolsPath = Path.Combine(Directory.GetCurrentDirectory(), Path.GetRandomFileName()); var packageObtainer = new ToolPackageObtainer( new DirectoryPath(toolsPath), GetUniqueTempProjectPathEachTest, new Lazy <string>(() => BundledTargetFramework.GetTargetFrameworkMoniker()), new PackageToProjectFileAdder(), new ProjectRestorer()); ToolConfigurationAndExecutableDirectory toolConfigurationAndExecutableDirectory = packageObtainer.ObtainAndReturnExecutablePath( packageId: TestPackageId, packageVersion: TestPackageVersion, nugetconfig: nugetConfigPath); var executable = toolConfigurationAndExecutableDirectory .ExecutableDirectory .WithFile( toolConfigurationAndExecutableDirectory .Configuration .ToolAssemblyEntryPoint); File.Exists(executable.Value) .Should() .BeTrue(executable + " should have the executable"); }
public void GivenAllButNoNugetConfigFilePathItCanDownloadThePackage() { var uniqueTempProjectPath = GetUniqueTempProjectPathEachTest(); var tempProjectDirectory = uniqueTempProjectPath.GetDirectoryPath(); var nugetConfigPath = WriteNugetConfigFileToPointToTheFeed(); var toolsPath = Path.Combine(Directory.GetCurrentDirectory(), Path.GetRandomFileName()); Directory.CreateDirectory(tempProjectDirectory.Value); /* * No nuget config means you don't need nuget config passed in during call * NuGet needs a way to find the package, in production, it will keep look up folders for Nuget.Config * and use the feed there. * In test, we don't want NuGet to keep look up, so we just copy paste beside the project. */ File.Copy(nugetConfigPath.Value, tempProjectDirectory.WithFile("nuget.config").Value); var packageObtainer = new ToolPackageObtainer( new DirectoryPath(toolsPath), () => uniqueTempProjectPath, new Lazy <string>(), new PackageToProjectFileAdder(), new ProjectRestorer()); ToolConfigurationAndExecutableDirectory toolConfigurationAndExecutableDirectory = packageObtainer.ObtainAndReturnExecutablePath( packageId: TestPackageId, packageVersion: TestPackageVersion, targetframework: _testTargetframework); var executable = toolConfigurationAndExecutableDirectory .ExecutableDirectory .WithFile( toolConfigurationAndExecutableDirectory .Configuration .ToolAssemblyEntryPoint); File.Exists(executable.Value) .Should() .BeTrue(executable + " should have the executable"); }
public void GivenAllButNoNugetConfigFilePathItCanDownloadThePackage() { var uniqueTempProjectPath = GetUniqueTempProjectPathEachTest(); var tempProjectDirectory = uniqueTempProjectPath.GetDirectoryPath(); var nugetConfigPath = WriteNugetConfigFileToPointToTheFeed(); var toolsPath = Path.Combine(Directory.GetCurrentDirectory(), Path.GetRandomFileName()); Directory.CreateDirectory(tempProjectDirectory.Value); /* * In test, we don't want NuGet to keep look up, so we point current directory to nugetconfig. */ Directory.SetCurrentDirectory(nugetConfigPath.GetDirectoryPath().Value); var packageObtainer = new ToolPackageObtainer( new DirectoryPath(toolsPath), () => uniqueTempProjectPath, new Lazy <string>(), new PackageToProjectFileAdder(), new ProjectRestorer()); ToolConfigurationAndExecutableDirectory toolConfigurationAndExecutableDirectory = packageObtainer.ObtainAndReturnExecutablePath( packageId: TestPackageId, packageVersion: TestPackageVersion, targetframework: _testTargetframework); var executable = toolConfigurationAndExecutableDirectory .ExecutableDirectory .WithFile( toolConfigurationAndExecutableDirectory .Configuration .ToolAssemblyEntryPoint); File.Exists(executable.Value) .Should() .BeTrue(executable + " should have the executable"); }
public void GivenAllButNoPackageVersionItCanDownloadThePackage() { var nugetConfigPath = WriteNugetConfigFileToPointToTheFeed(); var toolsPath = Path.Combine(Directory.GetCurrentDirectory(), Path.GetRandomFileName()); var packageObtainer = ConstructDefaultPackageObtainer(toolsPath); ToolConfigurationAndExecutableDirectory toolConfigurationAndExecutableDirectory = packageObtainer.ObtainAndReturnExecutablePath( packageId: TestPackageId, nugetconfig: nugetConfigPath, targetframework: _testTargetframework); var executable = toolConfigurationAndExecutableDirectory .ExecutableDirectory .WithFile( toolConfigurationAndExecutableDirectory .Configuration .ToolAssemblyEntryPoint); File.Exists(executable.Value) .Should() .BeTrue(executable + " should have the executable"); }