我使用Microsoft.CodeAnalysis和.MSBuild加载解决方案,它是项目并检索项目OutputFilePath。问题是调试和发布有不同的版本,我无法找到在解决方案配置之间切换的方法。知道如何设置将使用的配置吗?
MSBuildWorkspace workspace = MSBuildWorkspace.Create();
workspace.LoadMetadataForReferencedProjects = true;
Solution solution = workspace.OpenSolutionAsync("someSolution.sln").Result;
foreach (Project project in solution.Projects)
Console.Out.WriteLine(project.OutputFilePath);
workspace.CloseSolution();发布于 2017-04-13 10:21:06
一些MSBuild属性(通常是输出路径)依赖于构建项目的配置。在创建工作区时,必须指定该配置。
例如:
var properties = new Dictionary<string, string>
{
{ "Configuration", "Debug" } // Or "Release", or whatever is known to your projects.
// ... more properties that could influence your property,
// e.g. "Platform" ("x86", "AnyCPU", etc.)
};
MSBuildWorkspace workspace = MSBuildWorkspace.Create(properties);
workspace.LoadMetadataForReferencedProjects = true;
Solution solution = workspace.OpenSolutionAsync("someSolution.sln").Result;
foreach (Project project in solution.Projects)
Console.Out.WriteLine(project.OutputFilePath);
workspace.CloseSolution();https://stackoverflow.com/questions/43386267
复制相似问题