public BuildConfig(string configuration, string projectDir) { BuildConfiguration = configuration; ProjectDirectory = projectDir; SolutionDirectory = EnvironmentAnalyzer.LocateSolution(projectDir); Configuration = ConfigHelper.GetConfig(projectDir); }
private string LocateSolution(string solutionDirectory) { if (!string.IsNullOrEmpty(solutionDirectory) && Directory.EnumerateFiles(solutionDirectory, "*.sln").Any()) { return(null); } return(EnvironmentAnalyzer.LocateSolution(ProjectDirectory)); }
public void Execute(GeneratorExecutionContext context) { _context = context; if (!TryGet(context, "MSBuildProjectName", ref _projectName) || !TryGet(context, "MSBuildProjectDirectory", ref _projectDirectory) || !TryGet(context, "RootNamespace", ref _rootNamespace) || !TryGet(context, "Configuration", ref _buildConfiguration) || !TryGet(context, "TargetFrameworkIdentifier", ref _targetFrameworkAssembly) || !TryGet(context, "IntermediateOutputPath", ref _intermediateOutputDir)) { return; } SolutionDirectory = EnvironmentAnalyzer.LocateSolution(ProjectDirectory); _configurationPath = ConfigHelper.GetConfigurationPath(ProjectDirectory); Config = ConfigHelper.GetConfig(_configurationPath); try { Generate(); } catch (System.Exception ex) { if (Config.Debug) { context.ReportDiagnostic (Diagnostic.Create( new DiagnosticDescriptor( "MBT500", "DEBUG - Unhandled Error", "An Unhandled Generator Error Occurred: {0} - {1}", "DEBUG", DiagnosticSeverity.Error, true), null, ex.Message, ex.StackTrace)); } } }