public void GetSdkObjectFromGlobalJson() { //Arrange var sdkObject = new { project = new[] { "src", "test" }, sdk = new { version = "1.0.0", runtime = "coreclr", architecture = "arm" } }; FileSystemHelpers.Instance = MockFileSystem.GetMockFileSystem(@"x:\repo\global.json", () => JsonConvert.SerializeObject(sdkObject)); var arch = AspNet5Helper.GetDefaultAspNet5RuntimeArchitecture(); //Act var sdk = AspNet5Helper.GetAspNet5Sdk(@"x:\repo"); //Assert Assert.NotNull(sdk); Assert.Equal(sdkObject.sdk.version, sdk.Version); Assert.Equal(sdkObject.sdk.runtime, sdk.Runtime); Assert.Equal(sdkObject.sdk.architecture, sdk.Architecture); }
public AspNet5Builder(IEnvironment environment, IDeploymentSettingsManager settings, IBuildPropertyProvider propertyProvider, string sourcePath, string projectPath) : base(environment, settings, propertyProvider, sourcePath) { _projectPath = projectPath; var properties = propertyProvider.GetProperties(); properties[WellKnownEnvironmentVariables.KreVersion] = AspNet5Helper.GetAspNet5RuntimeVersion(sourcePath); }
public void GetSdkObjectWhenGlobalJsondDoesntHaveOne() { //Arrange var sdkObject = new { project = new[] { "src", "test" } }; FileSystemHelpers.Instance = MockFileSystem.GetMockFileSystem(@"x:\repo\global.json", () => JsonConvert.SerializeObject(sdkObject)); var arch = AspNet5Helper.GetDefaultAspNet5RuntimeArchitecture(); //Act var sdk = AspNet5Helper.GetAspNet5Sdk(@"x:\repo"); //Assert Assert.NotNull(sdk); Assert.Equal(Constants.DnxDefaultVersion, sdk.Version); Assert.Equal(Constants.DnxDefaultClr, sdk.Runtime); Assert.Equal(arch, sdk.Architecture); }
private ISiteBuilder ResolveProject(string repositoryRoot, string targetPath, IDeploymentSettingsManager perDeploymentSettings, IFileFinder fileFinder, bool tryWebSiteProject, SearchOption searchOption = SearchOption.AllDirectories, bool specificConfiguration = true) { if (DeploymentHelper.IsProject(targetPath)) { return(DetermineProject(repositoryRoot, targetPath, perDeploymentSettings, fileFinder)); } // Check for loose projects var projects = DeploymentHelper.GetProjects(targetPath, fileFinder, searchOption); if (projects.Count > 1) { // Can't determine which project to build throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_AmbiguousProjects, String.Join(", ", projects))); } else if (projects.Count == 1) { return(DetermineProject(repositoryRoot, projects[0], perDeploymentSettings, fileFinder)); } if (tryWebSiteProject) { // Website projects need a solution to build so look for one in the repository path // that has this website in it. var solutions = VsHelper.FindContainingSolutions(repositoryRoot, targetPath, fileFinder); // More than one solution is ambiguous if (solutions.Count > 1) { ThrowAmbiguousSolutionsError(solutions); } else if (solutions.Count == 1) { // Unambiguously pick the root return(new WebSiteBuilder(_environment, perDeploymentSettings, _propertyProvider, repositoryRoot, targetPath, solutions[0].Path)); } } // This should only ever happen if the user specifies an invalid directory. // The other case where the method is called we always resolve the path so it's a non issue there. if (specificConfiguration && !Directory.Exists(targetPath)) { throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Resources.Error_ProjectDoesNotExist, targetPath)); } // Check for ASP.NET 5 project without VS solution or project string projectJson; if (AspNet5Helper.TryAspNet5Project(targetPath, out projectJson)) { return(new AspNet5Builder(_environment, perDeploymentSettings, _propertyProvider, repositoryRoot, projectJson)); } // If there's none then use the basic builder (the site is xcopy deployable) return(ResolveNonAspProject(repositoryRoot, targetPath, perDeploymentSettings)); }