示例#1
0
        public async Task <FrcSettings?> GetFrcSettingsAsync()
        {
            bool verbose = m_buildSettingsProvider.Verbose;

            if (verbose)
            {
                await m_outputWriter.WriteLineAsync("Getting FRC Settings File").ConfigureAwait(false);
            }
            string projectDirectory = await m_projectInformationProvider.GetProjectRootDirectoryAsync().ConfigureAwait(false);

            string settingsFile = Path.Combine(projectDirectory, SettingsJsonFileName);
            string?json         = null;

            try
            {
                json = await m_fileReaderProvider.ReadFileAsStringAsync(settingsFile).ConfigureAwait(false);
            }
            catch (IOException)
            {
                // Locked or missing file, failed to read
                if (verbose)
                {
                    await m_outputWriter.WriteLineAsync("Could not read from settings file").ConfigureAwait(false);
                }
                return(null);
            }
            var deserializeSettings = new JsonSerializerSettings
            {
                MissingMemberHandling = MissingMemberHandling.Error
            };

            try
            {
                var settingsStore = await Task.Run(() => JsonConvert.DeserializeObject <FrcSettings>(json,
                                                                                                     deserializeSettings)).ConfigureAwait(false);

                if (verbose)
                {
                    await m_outputWriter.WriteLineAsync("Successfully read settings file").ConfigureAwait(false);
                }
                return(settingsStore);
            }
            catch (JsonSerializationException)
            {
                if (verbose)
                {
                    await m_outputWriter.WriteLineAsync("Could not parse settings file").ConfigureAwait(false);
                }
                return(null);
            }
        }
示例#2
0
        public async Task <string> GetWPILibUserFolderAsync()
        {
            // Netstandard does not support a way to get the user folder, so we will just use a WPILib folder in the project.
            string projectFolder = await m_projectInformationProvider.GetProjectRootDirectoryAsync().ConfigureAwait(false);

            return(Path.Combine(projectFolder, "wpilib"));
        }
示例#3
0
        public async Task BuildCodeAsync()
        {
            await m_outputWriter.WriteLineAsync("Starting code build").ConfigureAwait(false);

            string outputLoc = await m_projectInformationProvider.GetProjectBuildDirectoryAsync().ConfigureAwait(false);

            string projectDir = await m_projectInformationProvider.GetProjectRootDirectoryAsync().ConfigureAwait(false);

            var retVal = await Task.Run(() =>
            {
                string configuration = "Release";
                if (m_buildSettingsProvider.Debug)
                {
                    configuration = "Debug";
                }
                var cmdArgs = new List <string>
                {
                    projectDir,
                    "--configuration", configuration,
                    "-o", outputLoc
                };

                var result = Command.CreateDotNet("build", cmdArgs).Execute();
                return(result);
            }).ConfigureAwait(false);

            if (retVal.ExitCode != 0)
            {
                throw m_exceptionThrowerProvider.ThrowException($"Failed to build code. Error code: {retVal.ExitCode}");
            }
            await m_outputWriter.WriteLineAsync("Successfully built code").ConfigureAwait(false);
        }