Esempio n. 1
0
        public async Task <bool> PerformRebuildAsync(string projectFullPath, DateTime ifNotBuiltSince)
        {
            var pipeName = $"BlazorAutoRebuild\\{_vsProcess.Id}";

            using (var pipeClient = new NamedPipeClientStream(pipeName))
            {
                await pipeClient.ConnectAsync(_connectionTimeoutMilliseconds);

                // Protocol:
                //   1. Receive protocol version number from the VS listener
                //      If we're incompatible with it, send back special string "abort" and end
                //   2. Send the project path to the VS listener
                //   3. Send the 'if not rebuilt since' timestamp to the VS listener
                //   4. Wait for it to send back a bool representing the result
                // Keep in sync with AutoRebuildService.cs in the BlazorExtension project
                // In the future we may extend this to getting back build error details
                var remoteProtocolVersion = await pipeClient.ReadIntAsync();

                if (remoteProtocolVersion == 1)
                {
                    await pipeClient.WriteStringAsync(projectFullPath);

                    await pipeClient.WriteDateTimeAsync(ifNotBuiltSince);

                    return(await pipeClient.ReadBoolAsync());
                }
                else
                {
                    await pipeClient.WriteStringAsync("abort");

                    return(false);
                }
            }
        }