Visual Studio:通过 Power Console 添加项目文件失败 [英] Visual Studio:Adding project file via Power Console is failing

查看:39
本文介绍了Visual Studio:通过 Power Console 添加项目文件失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是在一个解决方案中添加 384 个现有项目,以便用项目依赖替换二进制文件依赖并使用 msbuild 进行构建.为此,我尝试使用 Visual Studio API 来自动将项目添加到解决方案中.

I've a task to add 384 existing projects in one solution in order to replace binary file dependency with project dependency and build with msbuild. To achieve this, I'm trying to use Visual Studio API in order to automate the adding of projects to a solution.

我实际上是 Windows Power Shell 的新手,我正在使用 Visual Studio 的 Power Console 插件在当前打开的解决方案中添加项目(*.csproj、*.vcxproj)文件,使用 $DTE.Solution.AddFromFile (http://msdn.microsoft.com/en-us/library/envdte80.solutionfolder.addfromfile),但它似乎不起作用.这是错误输出:

I'm actually newbie to Windows Power Shell and I'm using Power Console plugin for Visual Studio to add project (*.csproj, *.vcxproj) files in presently opened solution using $DTE.Solution.AddFromFile (http://msdn.microsoft.com/en-us/library/envdte80.solutionfolder.addfromfile), but it doesn't seems to be working. Here is the error output:

PS> $DTE.Solution.AddFromFile('WpfApplication1.csproj')
Exception calling "AddFromFile" with "2" argument(s): "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALID
ARG))"
At line:1 char:26
+ $DTE.Solution.AddFromFile <<<< ('WpfApplication1.csproj')
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

任何人都有通过 Power Console 使用 Visual Studio API 方法的任何提示?

Anyone have any tips to use Visual Studio API methods via Power Console?

法鲁克

推荐答案

您需要使用项目文件的完整路径.像这样:

You need to use full path to the project file. Like this:

PS> $DTE.Solution.AddFromFile('C:\Users\sv\Documents\Visual Studio 2010\Projects\ConsoleApplication1\ConsoleApplication2\ConsoleApplication2.csproj')

这篇关于Visual Studio:通过 Power Console 添加项目文件失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆