在Visual Studio 2013中,我制作了一个VsPackage,它可以调用可以为windows或linux构建的外部交叉编译工具。
我希望在安装我的vspackage时添加linux32和linux64作为可选平台(除了已经存在的Win32和x64)。用户不必自己手动添加任何平台(我的vspackage应初始化准备供他们选择的平台)。
这样我就可以检测到我的包中的平台名称字符串,并使用该平台的相应设置进行编译。
经过一番研究,我试着这样做:
_applicationObject = (DTE)GetService(typeof(DTE));
EnvDTE.Project project;
project = _applicationObject.Solution.Projects.Item(1);
project.ConfigurationManager.AddPlatform("Linux32", "Win32", true);
但它返回一个参数异常。
An exception of type 'System.ArgumentException' occurred in package_test.dll but was not handled in user code
Additional information: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
从VsPackage中添加平台的正确方法是什么(即以编程方式)?