Ejemplo n.º 1
0
    protected override IEnumerable <Action <XElement, string> > GetWebConfigActions()
    {
        yield return(WebConfigHelpers.AddOrModifyAspNetCoreSection(
                         key: "hostingModel",
                         value: DeploymentParameters.HostingModel.ToString()));

        yield return((element, _) =>
        {
            var aspNetCore = element
                             .Descendants("system.webServer")
                             .Single()
                             .GetOrAdd("aspNetCore");

            // Expand path to dotnet because IIS process would not inherit PATH variable
            if (aspNetCore.Attribute("processPath")?.Value.StartsWith("dotnet", StringComparison.Ordinal) == true)
            {
                aspNetCore.SetAttributeValue("processPath", DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture));
            }
        });

        yield return(WebConfigHelpers.AddOrModifyHandlerSection(
                         key: "modules",
                         value: AspNetCoreModuleV2ModuleName));

        foreach (var action in base.GetWebConfigActions())
        {
            yield return(action);
        }
    }
Ejemplo n.º 2
0
        public static async Task <GetResponse <TRet> > ExtractInfoFromProject <TRet>(string projPath, CancellationToken cancel, Func <Assembly, GetResponse <TRet> > getter)
        {
            if (cancel.IsCancellationRequested)
            {
                return(GetResponse <TRet> .Fail("Cancelled"));
            }

            // We copy to a temp folder, as despite all the hoops jumped through to unload the assembly,
            // it still seems to lock the dll files.  For whatever reason, though, deleting the folder
            // containing all those files seems to work out? This is definitely a hack.  Unload should
            // ideally just work out of the box.
            using var tempFolder = new TempFolder(Path.Combine(Paths.LoadingFolder, Path.GetRandomFileName()));
            if (cancel.IsCancellationRequested)
            {
                return(GetResponse <TRet> .Fail("Cancelled"));
            }
            CopyDirectory(Path.GetDirectoryName(projPath) !, tempFolder.Dir.Path, cancel);
            projPath = Path.Combine(tempFolder.Dir.Path, Path.GetFileName(projPath));
            var exec = await DotNetCommands.GetExecutablePath(projPath, cancel);

            if (exec.Failed)
            {
                return(exec.BubbleFailure <TRet>());
            }
            return(AssemblyLoading.ExecuteAndForceUnload(exec.Value, getter));
        }
Ejemplo n.º 3
0
        public async Task StartsWithDotnetInstallLocation(RuntimeArchitecture runtimeArchitecture)
        {
            var deploymentParameters = Fixture.GetBaseDeploymentParameters();

            deploymentParameters.RuntimeArchitecture = runtimeArchitecture;

            // IIS doesn't allow empty PATH
            deploymentParameters.EnvironmentVariables["PATH"] = ".";
            deploymentParameters.WebConfigActionList.Add(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", "dotnet"));

            // Key is always in 32bit view
            using (var localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
            {
                var installDir = DotNetCommands.GetDotNetInstallDir(runtimeArchitecture);
                using (new TestRegistryKey(
                           localMachine,
                           "SOFTWARE\\dotnet\\Setup\\InstalledVersions\\" + runtimeArchitecture,
                           "InstallLocation",
                           installDir))
                {
                    var deploymentResult = await DeployAsync(deploymentParameters);

                    await deploymentResult.AssertStarts();

                    StopServer();
                    // Verify that in this scenario dotnet.exe was found using InstallLocation lookup
                    // I would've liked to make a copy of dotnet directory in this test and use it for verification
                    // but dotnet roots are usually very large on dev machines so this test would take disproportionally long time and disk space
                    Assert.Equal(1, TestSink.Writes.Count(w => w.Message.Contains($"Found dotnet.exe in InstallLocation at '{installDir}\\dotnet.exe'")));
                }
            }
        }
Ejemplo n.º 4
0
        protected override IEnumerable <Action <XElement, string> > GetWebConfigActions()
        {
            if (IISDeploymentParameters.PublishApplicationBeforeDeployment)
            {
                // For published apps, prefer the content in the web.config, but update it.
                yield return(WebConfigHelpers.AddOrModifyAspNetCoreSection(
                                 key: "hostingModel",
                                 value: DeploymentParameters.HostingModel.ToString()));

                yield return(WebConfigHelpers.AddOrModifyHandlerSection(
                                 key: "modules",
                                 value: AspNetCoreModuleV2ModuleName));

                // We assume the x64 dotnet.exe is on the path so we need to provide an absolute path for x86 scenarios.
                // Only do it for scenarios that rely on dotnet.exe (Core, portable, etc.).
                if (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.CoreClr &&
                    DeploymentParameters.ApplicationType == ApplicationType.Portable &&
                    DotNetCommands.IsRunningX86OnX64(DeploymentParameters.RuntimeArchitecture))
                {
                    var executableName = DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture);
                    if (!File.Exists(executableName))
                    {
                        throw new Exception($"Unable to find '{executableName}'.'");
                    }
                    yield return(WebConfigHelpers.AddOrModifyAspNetCoreSection("processPath", executableName));
                }
            }

            foreach (var action in base.GetWebConfigActions())
            {
                yield return(action);
            }
        }
Ejemplo n.º 5
0
        public override async Task <DeploymentResult> DeployAsync()
        {
            using (Logger.BeginScope("Deployment"))
            {
                StartTimer();

                var contentRoot = string.Empty;
                if (string.IsNullOrEmpty(DeploymentParameters.ServerConfigTemplateContent))
                {
                    DeploymentParameters.ServerConfigTemplateContent = File.ReadAllText("IIS.config");
                }

                _application = new IISApplication(IISDeploymentParameters, Logger);

                // For now, only support using published output
                DeploymentParameters.PublishApplicationBeforeDeployment = true;

                if (DeploymentParameters.ApplicationType == ApplicationType.Portable)
                {
                    DefaultWebConfigActions.Add(
                        WebConfigHelpers.AddOrModifyAspNetCoreSection(
                            "processPath",
                            DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture)));
                }

                if (DeploymentParameters.PublishApplicationBeforeDeployment)
                {
                    DotnetPublish();
                    contentRoot = DeploymentParameters.PublishedApplicationRootPath;
                    // Do not override settings set on parameters
                    if (!IISDeploymentParameters.HandlerSettings.ContainsKey("debugLevel") &&
                        !IISDeploymentParameters.HandlerSettings.ContainsKey("debugFile"))
                    {
                        var logFile = Path.Combine(contentRoot, $"{_application.WebSiteName}.txt");
                        IISDeploymentParameters.HandlerSettings["debugLevel"] = "4";
                        IISDeploymentParameters.HandlerSettings["debugFile"]  = logFile;
                    }

                    DefaultWebConfigActions.Add(WebConfigHelpers.AddOrModifyHandlerSection(
                                                    key: "modules",
                                                    value: DeploymentParameters.AncmVersion.ToString()));
                    RunWebConfigActions(contentRoot);
                }

                var uri = TestUriHelper.BuildTestUri(ServerType.IIS, DeploymentParameters.ApplicationBaseUriHint);
                // To prevent modifying the IIS setup concurrently.
                await _application.StartIIS(uri, contentRoot);

                // Warm up time for IIS setup.
                Logger.LogInformation("Successfully finished IIS application directory setup.");
                return(new IISDeploymentResult(
                           LoggerFactory,
                           IISDeploymentParameters,
                           applicationBaseUri: uri.ToString(),
                           contentRoot: contentRoot,
                           hostShutdownToken: _hostShutdownToken.Token,
                           hostProcess: _application.HostProcess
                           ));
            }
        }
        public void Failure()
        {
            var lines = File.ReadAllLines(Utility.BuildFailureFile);

            DotNetCommands.TryGetExecutablePathFromOutput(lines, out var _)
            .Should().BeFalse();
        }
Ejemplo n.º 7
0
        public async Task <(string?MutagenVersion, string?SynthesisVersion)> GetLatestVersions(Version?dotNetVersion, bool includePrerelease)
        {
            try
            {
                if (dotNetVersion == null)
                {
                    Log.Logger.Error("Can not query for latest nuget versions as there is not dotnet SDK installed.");
                    return(null, null);
                }
                Log.Logger.Information("Querying for latest published library versions");
                var bootstrapProjectDir = new DirectoryPath(Path.Combine(Execution.Paths.WorkingDirectory, "VersionQuery"));
                bootstrapProjectDir.DeleteEntireFolder();
                bootstrapProjectDir.Create();
                var slnPath = Path.Combine(bootstrapProjectDir.Path, "VersionQuery.sln");
                SolutionInitialization.CreateSolutionFile(slnPath);
                var projPath = Path.Combine(bootstrapProjectDir.Path, "VersionQuery.csproj");
                SolutionInitialization.CreateProject(projPath, GameCategory.Skyrim, insertOldVersion: true);
                SolutionInitialization.AddProjectToSolution(slnPath, projPath);
                var ret = await DotNetCommands.QuerySynthesisVersions(projPath, current : false, includePrerelease : includePrerelease, CancellationToken.None);

                Log.Logger.Information("Latest published library versions:");
                Log.Logger.Information($"  Mutagen: {ret.MutagenVersion}");
                Log.Logger.Information($"  Synthesis: {ret.SynthesisVersion}");
                return(ret.MutagenVersion ?? this.MutagenVersion, ret.SynthesisVersion ?? this.SynthesisVersion);
            }
            catch (Exception ex)
            {
                Log.Logger.Error(ex, "Error querying for latest nuget versions");
                return(null, null);
            }
        }
        public void SuccessNonEnglish()
        {
            var lines = File.ReadAllLines(Utility.BuildSuccessNonEnglishFile);

            DotNetCommands.TryGetExecutablePathFromOutput(lines, out var path)
            .Should().BeTrue();
            path.Should().Be(@"C:\Users\Andrew\AppData\Local\Temp\Synthesis\Loading\ugqvnbdg.i1q\bin\Debug\net5.0\win-x64\FaceFixer.dll");
        }
        public void Success()
        {
            var lines = File.ReadAllLines(Utility.BuildSuccessFile);

            DotNetCommands.TryGetExecutablePathFromOutput(lines, out var path)
            .Should().BeTrue();
            path.Should().Be(@"C:\Repos\Patchers\khajiitearsshow\KhajiitEarsShow\bin\Debug\net5.0\KhajiitEarsShow.dll");
        }
 public void DepreciatedNugetParse()
 {
     DotNetCommands.TryParseLibraryLine(
         "   > Mutagen.Bethesda.Synthesis      0.10.7.0    0.10.7 (D)   0.10.8.1",
         out var package,
         out var requested,
         out var resolved,
         out var latest)
     .Should().BeTrue();
     package.Should().Be("Mutagen.Bethesda.Synthesis");
     requested.Should().Be("0.10.7.0");
     resolved.Should().Be("0.10.7");
     latest.Should().Be("0.10.8.1");
 }
Ejemplo n.º 11
0
 private void ModifyDotNetExePathInWebConfig()
 {
     // We assume the x64 dotnet.exe is on the path so we need to provide an absolute path for x86 scenarios.
     // Only do it for scenarios that rely on dotnet.exe (Core, portable, etc.).
     if (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.CoreClr &&
         DeploymentParameters.ApplicationType == ApplicationType.Portable &&
         DotNetCommands.IsRunningX86OnX64(DeploymentParameters.RuntimeArchitecture))
     {
         var executableName = DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture);
         if (!File.Exists(executableName))
         {
             throw new Exception($"Unable to find '{executableName}'.'");
         }
         ModifyAspNetCoreSectionInWebConfig("processPath", executableName);
     }
 }
Ejemplo n.º 12
0
    protected string GetDotNetExeForArchitecture()
    {
        var executableName = DotnetCommandName;

        // We expect x64 dotnet.exe to be on the path but we have to go searching for the x86 version.
        if (DotNetCommands.IsRunningX86OnX64(DeploymentParameters.RuntimeArchitecture))
        {
            executableName = DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture);
            if (!File.Exists(executableName))
            {
                throw new Exception($"Unable to find '{executableName}'.'");
            }
        }

        return(executableName);
    }
Ejemplo n.º 13
0
 public async Task Prep(GameRelease release, CancellationToken cancel)
 {
     await Task.WhenAll(
         Task.Run(async() =>
     {
         _output.OnNext($"Compiling");
         var resp = await DotNetCommands.Compile(PathToProject, cancel, _output.OnNext).ConfigureAwait(false);
         if (!resp.Succeeded)
         {
             throw new SynthesisBuildFailure(resp.Reason);
         }
     }),
         Task.Run(async() =>
     {
         await CopyOverExtraData().ConfigureAwait(false);
     })).ConfigureAwait(false);;
 }
Ejemplo n.º 14
0
        private string GetIISExpressPath()
        {
            var programFiles = "Program Files";

            if (DotNetCommands.IsRunningX86OnX64(DeploymentParameters.RuntimeArchitecture))
            {
                programFiles = "Program Files (x86)";
            }

            // Get path to program files
            var iisExpressPath = Path.Combine(Environment.GetEnvironmentVariable("SystemDrive") + "\\", programFiles, "IIS Express", "iisexpress.exe");

            if (!File.Exists(iisExpressPath))
            {
                throw new Exception("Unable to find IISExpress on the machine: " + iisExpressPath);
            }

            return(iisExpressPath);
        }
Ejemplo n.º 15
0
        protected override IEnumerable <Action <XElement, string> > GetWebConfigActions()
        {
            if (DeploymentParameters.ApplicationType == ApplicationType.Portable)
            {
                yield return(WebConfigHelpers.AddOrModifyAspNetCoreSection(
                                 "processPath",
                                 DotNetCommands.GetDotNetExecutable(DeploymentParameters.RuntimeArchitecture)));
            }

            yield return(WebConfigHelpers.AddOrModifyHandlerSection(
                             key: "modules",
                             value: DeploymentParameters.AncmVersion.ToString()));


            foreach (var action in base.GetWebConfigActions())
            {
                yield return(action);
            }
        }
Ejemplo n.º 16
0
        public static async Task <ConfigurationState <RunnerRepoInfo> > CheckoutRunnerRepository(
            string proj,
            string localRepoDir,
            GitPatcherVersioning patcherVersioning,
            NugetVersioningTarget nugetVersioning,
            Action <string>?logger,
            CancellationToken cancel,
            bool compile = true)
        {
            try
            {
                cancel.ThrowIfCancellationRequested();

                logger?.Invoke($"Targeting {patcherVersioning}");

                using var repo = new Repository(localRepoDir);
                var runnerBranch = repo.Branches[RunnerBranch] ?? repo.CreateBranch(RunnerBranch);
                repo.Reset(ResetMode.Hard);
                Commands.Checkout(repo, runnerBranch);
                string?targetSha;
                string?target;
                bool   fetchIfMissing = patcherVersioning.Versioning switch
                {
                    PatcherVersioningEnum.Commit => true,
                    _ => false
                };
                switch (patcherVersioning.Versioning)
                {
                case PatcherVersioningEnum.Tag:
                    if (string.IsNullOrWhiteSpace(patcherVersioning.Target))
                    {
                        return(GetResponse <RunnerRepoInfo> .Fail("No tag selected"));
                    }
                    repo.Fetch();
                    targetSha = repo.Tags[patcherVersioning.Target]?.Target.Sha;
                    if (string.IsNullOrWhiteSpace(targetSha))
                    {
                        return(GetResponse <RunnerRepoInfo> .Fail("Could not locate tag"));
                    }
                    target = patcherVersioning.Target;
                    break;

                case PatcherVersioningEnum.Commit:
                    targetSha = patcherVersioning.Target;
                    if (string.IsNullOrWhiteSpace(targetSha))
                    {
                        return(GetResponse <RunnerRepoInfo> .Fail("Could not locate commit"));
                    }
                    target = patcherVersioning.Target;
                    break;

                case PatcherVersioningEnum.Branch:
                    if (string.IsNullOrWhiteSpace(patcherVersioning.Target))
                    {
                        return(GetResponse <RunnerRepoInfo> .Fail($"Target branch had no name."));
                    }
                    repo.Fetch();
                    var targetBranch = repo.Branches[patcherVersioning.Target];
                    if (targetBranch == null)
                    {
                        return(GetResponse <RunnerRepoInfo> .Fail($"Could not locate branch: {patcherVersioning.Target}"));
                    }
                    targetSha = targetBranch.Tip.Sha;
                    target    = patcherVersioning.Target;
                    break;

                default:
                    throw new NotImplementedException();
                }
                if (!ObjectId.TryParse(targetSha, out var objId))
                {
                    return(GetResponse <RunnerRepoInfo> .Fail("Malformed sha string"));
                }

                cancel.ThrowIfCancellationRequested();
                var commit = repo.Lookup(objId, ObjectType.Commit) as Commit;
                if (commit == null)
                {
                    if (!fetchIfMissing)
                    {
                        return(GetResponse <RunnerRepoInfo> .Fail("Could not locate commit with given sha"));
                    }
                    repo.Fetch();
                    commit = repo.Lookup(objId, ObjectType.Commit) as Commit;
                    if (commit == null)
                    {
                        return(GetResponse <RunnerRepoInfo> .Fail("Could not locate commit with given sha"));
                    }
                }

                cancel.ThrowIfCancellationRequested();
                var slnPath = GitPatcherRun.GetPathToSolution(localRepoDir);
                if (slnPath == null)
                {
                    return(GetResponse <RunnerRepoInfo> .Fail("Could not locate solution to run."));
                }

                var foundProjSubPath = SolutionPatcherRun.AvailableProject(slnPath, proj);

                if (foundProjSubPath == null)
                {
                    return(GetResponse <RunnerRepoInfo> .Fail($"Could not locate target project file: {proj}."));
                }

                cancel.ThrowIfCancellationRequested();
                logger?.Invoke($"Checking out {targetSha}");
                repo.Reset(ResetMode.Hard, commit, new CheckoutOptions());

                var projPath = Path.Combine(localRepoDir, foundProjSubPath);

                cancel.ThrowIfCancellationRequested();
                logger?.Invoke($"Mutagen Nuget: {nugetVersioning.MutagenVersioning} {nugetVersioning.MutagenVersion}");
                logger?.Invoke($"Synthesis Nuget: {nugetVersioning.SynthesisVersioning} {nugetVersioning.SynthesisVersion}");
                GitPatcherRun.SwapInDesiredVersionsForSolution(
                    slnPath,
                    drivingProjSubPath: foundProjSubPath,
                    mutagenVersion: nugetVersioning.MutagenVersioning == NugetVersioningEnum.Match ? null : nugetVersioning.MutagenVersion,
                    listedMutagenVersion: out var listedMutagenVersion,
                    synthesisVersion: nugetVersioning.SynthesisVersioning == NugetVersioningEnum.Match ? null : nugetVersioning.SynthesisVersion,
                    listedSynthesisVersion: out var listedSynthesisVersion);

                var runInfo = new RunnerRepoInfo(
                    slnPath: slnPath,
                    projPath: projPath,
                    target: target,
                    commitMsg: commit.Message,
                    commitDate: commit.Author.When.LocalDateTime,
                    listedSynthesis: listedSynthesisVersion,
                    listedMutagen: listedMutagenVersion);

                // Compile to help prep
                if (compile)
                {
                    var compileResp = await DotNetCommands.Compile(projPath, cancel, logger);

                    logger?.Invoke("Finished compiling");
                    if (compileResp.Failed)
                    {
                        return(compileResp.BubbleResult(runInfo));
                    }
                }

                return(GetResponse <RunnerRepoInfo> .Succeed(runInfo));
            }
            catch (OperationCanceledException)
            {
                throw;
            }
            catch (Exception ex)
            {
                return(GetResponse <RunnerRepoInfo> .Fail(ex));
            }
        }
Ejemplo n.º 17
0
        static async Task DoWork(
            string? mutagenVersion,
            string? synthesisVersion,
            CancellationToken cancel)
        {
            using var temp = TempFolder.Factory();
            var failedDeps = new List<Dependent>();
            var projResults = new List<(Dependent, string, ErrorResponse)>();

            mutagenVersion ??= Versions.MutagenVersion;
            synthesisVersion ??= Versions.SynthesisVersion;

            System.Console.WriteLine($"Mutagen: {mutagenVersion}");
            System.Console.WriteLine($"Synthesis: {synthesisVersion}");

            var deps = await GitHubDependents.GitHubDependents.GetDependents(
                    user: RegistryConstants.GithubUser,
                    repository: RegistryConstants.GithubRepoName,
                    packageID: RegistryConstants.PackageId,
                    pages: byte.MaxValue)
                .ToArrayAsync();

            await Task.WhenAll(deps.GroupBy(x => x.User).Select(group => Task.Run(async () =>
            {
                cancel.ThrowIfCancellationRequested();
                if (group.Key == null) return;

                await Task.WhenAll(group.Select(dependency => Task.Run(async () =>
                {
                    cancel.ThrowIfCancellationRequested();
                    try
                    {
                        if (dependency.User.IsNullOrWhitespace() || dependency.Repository.IsNullOrWhitespace()) return;
                        var repoDir = Directory.CreateDirectory(Path.Combine(temp.Dir.Path, group.Key, dependency.Repository));
                        var clonePath = $"https://github.com/{dependency.User}/{dependency.Repository}";
                        try
                        {
                            Repository.Clone(clonePath, repoDir.FullName);
                        }
                        catch (Exception ex)
                        {
                            System.Console.Error.WriteLine($"Failed to clone {clonePath}");
                            System.Console.Error.WriteLine(ex);
                            failedDeps.Add(dependency);
                            return;
                        }

                        cancel.ThrowIfCancellationRequested();
                        using var repo = new Repository(repoDir.FullName);
                        var slnPath = GitPatcherRun.GetPathToSolution(repo.Info.WorkingDirectory);
                        if (slnPath == null)
                        {
                            System.Console.Error.WriteLine($"Could not get path to solution {clonePath}");
                            failedDeps.Add(dependency);
                            return;
                        }

                        GitPatcherRun.SwapInDesiredVersionsForSolution(
                            solutionPath: slnPath,
                            drivingProjSubPath: string.Empty,
                            mutagenVersion: mutagenVersion,
                            out var _,
                            synthesisVersion: synthesisVersion,
                            out var _);

                        foreach (var proj in SolutionPatcherRun.AvailableProjectSubpaths(slnPath))
                        {
                            System.Console.WriteLine($"Checking {group.Key}/{dependency.Repository}:{proj}");
                            cancel.ThrowIfCancellationRequested();
                            var path = Path.Combine(repoDir.FullName, proj);
                            var compile = await DotNetCommands.Compile(path, cancel, null);
                            if (compile.Failed)
                            {
                                System.Console.WriteLine("Failed compilation");
                            }
                            projResults.Add((dependency, proj, compile));
                        }
                    }
                    catch (Exception ex)
                    {
                        System.Console.Error.WriteLine($"Failed to check {dependency}");
                        System.Console.Error.WriteLine(ex);
                        return;
                    }
                })));
            })));

            cancel.ThrowIfCancellationRequested();
            System.Console.WriteLine();
            System.Console.WriteLine();
            System.Console.WriteLine();
            System.Console.WriteLine("-------------------------------");
            System.Console.WriteLine();
            System.Console.WriteLine();
            System.Console.WriteLine();

            if (failedDeps.Count > 0)
            {
                System.Console.WriteLine("Failed repos:");
                foreach (var f in failedDeps
                    .OrderBy(d => d.User)
                    .CreateOrderedEnumerable(d => d.Repository, null, true))
                {
                    System.Console.WriteLine($"   {f}");
                }
            }

            var failed = projResults.Where(p => p.Item3.Failed).ToList();
            if (failed.Count > 0)
            {
                System.Console.WriteLine("Failed projects:");
                foreach (var f in failed.OrderBy(f => f.Item1.User)
                    .CreateOrderedEnumerable(d => d.Item1.Repository, null, true)
                    .CreateOrderedEnumerable(d => d.Item2, null, true))
                {
                    System.Console.WriteLine($"{f.Item1}: {f.Item2}");
                    System.Console.WriteLine();
                }
            }
        }
Ejemplo n.º 18
0
        public async Task StartsWithPortableAndBootstraperExe()
        {
            var deploymentParameters = _fixture.GetBaseDeploymentParameters(_fixture.InProcessTestSite, publish: true);

            // We need the right dotnet on the path in IIS
            deploymentParameters.EnvironmentVariables["PATH"] = Path.GetDirectoryName(DotNetCommands.GetDotNetExecutable(deploymentParameters.RuntimeArchitecture));

            // rest publisher as it doesn't support additional parameters
            deploymentParameters.ApplicationPublisher = null;
            // ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482
            deploymentParameters.AdditionalPublishParameters = "-p:RuntimeIdentifier=win7-x64 -p:UseAppHost=true -p:SelfContained=false -p:ReferenceTestTasks=false";
            var deploymentResult = await DeployAsync(deploymentParameters);

            Assert.True(File.Exists(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.exe")));
            Assert.False(File.Exists(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll")));
            Assert.Contains("InProcessWebSite.exe", Helpers.ReadAllTextFromFile(Path.Combine(deploymentResult.ContentRoot, "web.config"), Logger));

            await deploymentResult.AssertStarts();
        }
Ejemplo n.º 19
0
        public async Task StartsWithPortableAndBootstraperExe()
        {
            var deploymentParameters = Fixture.GetBaseDeploymentParameters(Fixture.InProcessTestSite);

            deploymentParameters.TransformPath((path, root) => "InProcessWebSite.exe");
            deploymentParameters.TransformArguments((arguments, root) => "");

            // We need the right dotnet on the path in IIS
            deploymentParameters.EnvironmentVariables["PATH"] = Path.GetDirectoryName(DotNetCommands.GetDotNetExecutable(deploymentParameters.RuntimeArchitecture));

            // ReferenceTestTasks is workaround for https://github.com/dotnet/sdk/issues/2482
            var deploymentResult = await DeployAsync(deploymentParameters);

            Assert.True(File.Exists(Path.Combine(deploymentResult.ContentRoot, "InProcessWebSite.exe")));
            Assert.False(File.Exists(Path.Combine(deploymentResult.ContentRoot, "hostfxr.dll")));
            Assert.Contains("InProcessWebSite.exe", Helpers.ReadAllTextFromFile(Path.Combine(deploymentResult.ContentRoot, "web.config"), Logger));

            await deploymentResult.AssertStarts();
        }
Ejemplo n.º 20
0
 public void TestVersionString(string str, bool shouldSucceed)
 {
     DotNetCommands.GetDotNetVersion(str)
     .Acceptable.Should().Be(shouldSucceed);
 }
Ejemplo n.º 21
0
        public MainVM(Window window)
        {
            _window = window;
            var dotNet = Observable.Interval(TimeSpan.FromSeconds(10), RxApp.TaskpoolScheduler)
                         .StartWith(0)
                         .SelectTask(async i =>
            {
                try
                {
                    var ret = await DotNetCommands.DotNetSdkVersion(CancellationToken.None);
                    Log.Logger.Information($"dotnet SDK: {ret}");
                    return(ret);
                }
                catch (Exception ex)
                {
                    Log.Logger.Error(ex, $"Error retrieving dotnet SDK version");
                    return(default(Version?));
                }
            });

            DotNetSdkInstalled = dotNet
                                 .Take(1)
                                 .Merge(dotNet
                                        .FirstAsync(v => v != null))
                                 .DistinctUntilChanged()
                                 .Replay(1)
                                 .RefCount();

            Configuration        = new ConfigurationVM(this);
            ActivePanel          = Configuration;
            DiscardActionCommand = NoggogCommand.CreateFromObject(
                objectSource: this.WhenAnyValue(x => x.TargetConfirmation),
                canExecute: target => target != null,
                execute: (_) =>
            {
                TargetConfirmation = null;
            },
                disposable: this.CompositeDisposable);
            ConfirmActionCommand = NoggogCommand.CreateFromObject(
                objectSource: this.WhenAnyFallback(x => x.TargetConfirmation !.ToDo),
                canExecute: toDo => toDo != null,
                execute: toDo =>
            {
                toDo?.Invoke();
                TargetConfirmation = null;
            },
                disposable: this.CompositeDisposable);

            _Hot = this.WhenAnyValue(x => x.ActivePanel)
                   .Select(x =>
            {
                switch (x)
                {
                case ConfigurationVM config:
                    return(config.WhenAnyFallback(x => x.CurrentRun !.Running, fallback: false));

                case PatchersRunVM running:
                    return(running.WhenAnyValue(x => x.Running));

                default:
                    break;
                }
                return(Observable.Return(false));
            })
                   .Switch()
                   .DistinctUntilChanged()
                   .ToGuiProperty(this, nameof(Hot));

            OpenProfilesPageCommand = ReactiveCommand.Create(() =>
            {
                ActivePanel = new ProfilesDisplayVM(Configuration, ActivePanel);
            },
                                                             canExecute: Observable.CombineLatest(
                                                                 this.WhenAnyFallback(x => x.Configuration.CurrentRun !.Running, fallback: false),
                                                                 this.WhenAnyValue(x => x.ActivePanel)
                                                                 .Select(x => x is ProfilesDisplayVM),
                                                                 (running, isProfile) => !running && !isProfile));

            IdeOptions.AddRange(EnumExt.GetValues <IDE>());

            Task.Run(() => Mutagen.Bethesda.WarmupAll.Init()).FireAndForget();

            SynthesisVersion = Mutagen.Bethesda.Synthesis.Versions.SynthesisVersion;
            MutagenVersion   = Mutagen.Bethesda.Synthesis.Versions.MutagenVersion;

            var latestVersions = Observable.Return(Unit.Default)
                                 .ObserveOn(RxApp.TaskpoolScheduler)
                                 .CombineLatest(
                DotNetSdkInstalled,
                (_, v) => v)
                                 .SelectTask(async v =>
            {
                var normalUpdateTask     = GetLatestVersions(v, includePrerelease: false);
                var prereleaseUpdateTask = GetLatestVersions(v, includePrerelease: true);
                await Task.WhenAll(normalUpdateTask, prereleaseUpdateTask);
                return(Normal: await normalUpdateTask, Prerelease: await prereleaseUpdateTask);
            })
                                 .Replay(1)
                                 .RefCount();

            NewestMutagenVersion = Observable.CombineLatest(
                latestVersions,
                this.WhenAnyFallback(x => x.Configuration.SelectedProfile !.ConsiderPrereleaseNugets),
                (vers, prereleases) => prereleases ? vers.Prerelease.MutagenVersion : vers.Normal.MutagenVersion)
                                   .Replay(1)
                                   .RefCount();
            NewestSynthesisVersion = Observable.CombineLatest(
                latestVersions,
                this.WhenAnyFallback(x => x.Configuration.SelectedProfile !.ConsiderPrereleaseNugets),
                (vers, prereleases) => prereleases ? vers.Prerelease.SynthesisVersion : vers.Normal.SynthesisVersion)
                                     .Replay(1)
                                     .RefCount();

            // Switch to DotNet screen if missing
            DotNetSdkInstalled
            .Subscribe(v =>
            {
                if (v == null)
                {
                    ActivePanel = new DotNetNotInstalledVM(this, this.ActivePanel, DotNetSdkInstalled);
                }
            });

            _ActiveConfirmation = Observable.CombineLatest(
                this.WhenAnyFallback(x => x.Configuration.SelectedProfile !.SelectedPatcher)
                .Select(x =>
            {
                if (x is not GitPatcherVM gitPatcher)
                {
                    return(Observable.Return(default(GitPatcherVM?)));
                }
                return(gitPatcher.WhenAnyValue(x => x.PatcherSettings.SettingsOpen)
                       .Select(open => open ? (GitPatcherVM?)gitPatcher : null));
            })
                .Switch(),
                this.WhenAnyValue(x => x.TargetConfirmation),
                (openPatcher, target) =>
            {
                if (target != null)
                {
                    return(target);
                }
                if (openPatcher == null)
                {
                    return(default(ConfirmationActionVM?));
                }
                return(new ConfirmationActionVM(
                           "External Patcher Settings Open",
                           $"{openPatcher.Nickname} is open for settings manipulation.",
                           toDo: null));
            })
                                  .ToGuiProperty(this, nameof(ActiveConfirmation), default(ConfirmationActionVM?));

            _InModal = this.WhenAnyValue(x => x.ActiveConfirmation)
                       .Select(x => x != null)
                       .ToGuiProperty(this, nameof(InModal));
        }