public bool Generate(NuGetReference analyzeRef, string sqaleFilePath)
{
// sqale file path is optional
if (analyzeRef == null)
{
throw new ArgumentNullException("analyzeRef");
}
string baseDirectory = Path.Combine(
Path.GetTempPath(),
Assembly.GetEntryAssembly().GetName().Name);
string nuGetDirectory = Path.Combine(baseDirectory, ".nuget");
NuGetPackageHandler downloader = new NuGetPackageHandler(logger);
IPackage package = downloader.FetchPackage(NuGetPackageSource, analyzeRef.PackageId, analyzeRef.Version, nuGetDirectory);
if (package != null)
{
// TODO: support multiple languages
string language = SupportedLanguages.CSharp;
PluginManifest pluginDefn = CreatePluginDefinition(package);
string outputDirectory = Path.Combine(baseDirectory, ".output", Guid.NewGuid().ToString());
Directory.CreateDirectory(outputDirectory);
string rulesFilePath = Path.Combine(outputDirectory, "rules.xml");
// TODO: we shouldn't try to work out where the content files have been installed by NuGet.
// Instead, we should use the methods on IPackage to locate the assemblies e.g. Package.GetFiles()
string packageDirectory = Path.Combine(nuGetDirectory, package.Id + "." + package.Version.ToString());
Debug.Assert(Directory.Exists(packageDirectory), "Expected package directory does not exist: {0}", packageDirectory);
bool success = TryGenerateRulesFile(packageDirectory, nuGetDirectory, rulesFilePath);
if (success)
{
BuildPlugin(analyzeRef, sqaleFilePath, language, pluginDefn, rulesFilePath, outputDirectory, package);
}
}
return package != null;
}