VS2012 で利用可能なプラットフォーム ツールセットを一覧表示する方法はありますか? v90、v100、v110、v110_xp、および外部から提供されたプラットフォーム ツールセットを含むリストを意味します。別の方法 (より簡単にする必要があります): 特定のプラットフォーム ツールセットがインストールされているかどうかを確認する方法はありますか?
2244 次
1 に答える
3
ツールセットのリストを (使用可能な構成ごとに) ダンプするコンソール アプリ ユーティリティ (C#) を次に示します。Microsoft.Build
コンパイルできるようにするには、への参照を追加する必要があります。ツールセットの適切なリストは、ビルドするプロジェクトに依存することに注意してください。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace ListToolsets
{
class Program
{
static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Format is ListToolsets <project file path>");
return;
}
foreach (var toolset in PlatformToolset.GetPlatformToolsets(args[0]))
{
Console.WriteLine(toolset.Platform);
foreach (string ts in toolset.Toolsets)
{
Console.WriteLine(" " + ts);
}
}
}
}
public class PlatformToolset
{
private PlatformToolset()
{
Toolsets = new List<string>();
}
public string Platform { get; private set; }
public IList<string> Toolsets { get; private set; }
public static IList<PlatformToolset> GetPlatformToolsets(string projectPath)
{
var list = new List<PlatformToolset>();
var project = new Microsoft.Build.Evaluation.Project(projectPath);
AddPlatformToolsets(project, @"$(VCTargetsPath14)\Platforms", list);
AddPlatformToolsets(project, @"$(VCTargetsPath12)\Platforms", list);
AddPlatformToolsets(project, @"$(VCTargetsPath11)\Platforms", list);
AddPlatformToolsets(project, @"$(VCTargetsPath10)\Platforms", list);
return list;
}
private static void AddPlatformToolsets(Microsoft.Build.Evaluation.Project project, string path, IList<PlatformToolset> list)
{
string platforms = Path.GetFullPath(project.ExpandString(path));
if (!Directory.Exists(platforms))
return;
foreach (string platformPath in Directory.GetDirectories(platforms))
{
string platform = Path.GetFileName(platformPath);
PlatformToolset ts = list.FirstOrDefault(t => t.Platform == platform);
if (ts == null)
{
ts = new PlatformToolset();
ts.Platform = platform;
list.Add(ts);
}
foreach (string toolset in Directory.GetDirectories(Path.Combine(platformPath, "PlatformToolsets")))
{
string name = Path.GetFileName(toolset);
string friendlyName = project.GetPropertyValue("_PlatformToolsetFriendlyNameFor_" + name);
ts.Toolsets.Add(string.IsNullOrWhiteSpace(friendlyName) ? name : friendlyName);
}
}
}
}
}
于 2014-07-09T16:07:16.223 に答える