コード例 #1
0
        /// <summary>
        /// Commits the lock file contained in <see cref="LockFile"/> and the MSBuild targets/props to
        /// the local file system.
        /// </summary>
        /// <remarks>If <see cref="PreviousLockFile"/> and <see cref="LockFile"/> are identical
        ///  the file will not be written to disk.</remarks>
        /// <param name="forceWrite">Write out the lock file even if no changes exist.</param>
        public async Task CommitAsync(ILogger log, bool forceWrite, CancellationToken token)
        {
            // Write the lock file
            var lockFileFormat = new LockFileFormat();

            await CommitAsync(
                lockFileFormat,
                result : this,
                log : log,
                forceWrite : forceWrite,
                toolCommit : false,
                token : token);

            foreach (var toolRestoreResult in ToolRestoreResults)
            {
                if (toolRestoreResult.LockFilePath != null && toolRestoreResult.LockFile != null)
                {
                    await CommitAsync(
                        lockFileFormat,
                        result : toolRestoreResult,
                        log : log,
                        forceWrite : forceWrite,
                        toolCommit : true,
                        token : token);
                }
            }

            MSBuild.Commit(log);
        }