コード例 #1
0
        private string CopyFiles(string codeQualityProfilePackageName, string targetVersion)
        {
            var nuGetPackagePath = _nuGetPathHelper.GetPackageContentPath(codeQualityProfilePackageName, targetVersion);
            var ruleSetFilePath  = _directoryHelper.GetFiles(nuGetPackagePath, "*.ruleset").FirstOrDefault();

            if (string.IsNullOrWhiteSpace(ruleSetFilePath))
            {
                throw new InvalidOperationException($"Could not locate a *.ruleset file in the package folder '{nuGetPackagePath}'.");
            }

            var ruleSetFileName      = Path.GetFileName(ruleSetFilePath);
            var localRuleSetFilePath = Path.Combine(_basePath, ruleSetFileName);

            _logger.LogInformation($"Moving file {ruleSetFilePath} to {localRuleSetFilePath} ...");
            _fileHelper.Copy(ruleSetFilePath, localRuleSetFilePath, true);

            if (HasSolutionFile)
            {
                var dotsettingsFilePath = _directoryHelper.GetFiles(nuGetPackagePath, "*.DotSettings").FirstOrDefault();
                if (string.IsNullOrWhiteSpace(dotsettingsFilePath))
                {
                    throw new InvalidOperationException($"Could not locate a *.DotSettings file in the package folder '{nuGetPackagePath}'.");
                }

                var localDotDettingsFilePath = Path.Combine(_basePath, $"{_solutionFileName}.DotSettings");
                _logger.LogInformation($"Moving file {dotsettingsFilePath} to {localDotDettingsFilePath} ...");
                _fileHelper.Copy(dotsettingsFilePath, localDotDettingsFilePath, true);
            }

            return(localRuleSetFilePath);
        }