本文介绍了我怎样才能t4的脚手架从powershell.exe?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的NuGet的PM控制台是伟大的,所有,但你必须要在Visual Studio中使用它。我以前也问过这个问题,没有任何ansewr,我很难相信这是对话题的文档。

NuGet's PM console is great and all but you have to be in Visual Studio to use it. I have asked this question before without any ansewr and I find it hard to believe there is no documentation on the topic.

我有两个用户:用户A卖鞋,用户B销售的汽车。每个人都有不同的属性的需求。
如果我让他们写有需要的属性/数据类型各自Product.cs的实体,我该如何使用PowerShell.exe为:

I have two users: User A sell shoes, User B sells cars. Each have different property needs.If I allow them to write there needed properties/datatypes to their respective Product.cs entity, how can I use PowerShell.exe to:

脚手架控制器,视图的DbContext和库?

Scaffold the controller, views, dbcontext and repositories?

我知道我可以做的MSBuild算账,但它是如何似乎有没有办法使用PowerShell与比如说一个bat文件做脚手架VS 2010以外?

I know I can do a MSBuild afterwards, but how is it there seems to be no way to use PowerShell from say a bat file to do the scaffolding outside VS 2010?

任何有识之士将AP preciated。

Any insight would be appreciated.

推荐答案

我终于没有运气的天后想通了这一点。首先,不使用任何微软测试版,含的Windows 8开发版的PowerShell 3.0和VS 2011年一旦你的PowerShell 2.0和运行:

I finally figured this out after days of no luck. First and foremost, do not use any Microsoft betas, incl Windows 8 Developer Edition, PowerShell 3.0 and VS 2011. Once you have PowerShell 2.0 up and running:

1。在PS / 1.0文件夹中添加一个文件powershell.exe.config:

请点击此链接为脚本:http://connect.microsoft.com/PowerShell/feedback/details/525435/net-4-0-assemblies-and-powershell-v2

重新启动PowerShell 2.0和它现在将支持4.0框架。

restart PowerShell 2.0 and it will now support 4.0 framework.

2。设置执行策略为只需要远程脚本能征:

命令行:集ExecutionPolicy RemoteSigned就是

Command line: Set-ExecutionPolicy RemoteSigned

3。导入所需的自定义T4架子工(所以你可以使用T4支架):

命令行:导入模块C:\\用户\\管理\\文档\\的Visual Studio 2010\"\\Projects\\MvcApplication1\\packages\\T4Scaffolding.1.0.5\\tools\\T4Scaffolding.NuGetServices.dll

Command Line: import-module C:\Users\Admin\Documents\"Visual Studio 2010"\Projects\MvcApplication1\packages\T4Scaffolding.1.0.5\tools\T4Scaffolding.NuGetServices.dll

命令行:导入模块C:\\用户\\管理\\文档\\的Visual Studio 2010\\项目\\ MvcApplication1 \\包\\ T4Scaffolding.1.0.5 \\工具\\ T4Scaffolding.dll

Command Line: import-module C:\Users\Admin\Documents\"Visual Studio 2010"\Projects\MvcApplication1\packages\T4Scaffolding.1.0.5\tools\T4Scaffolding.dll

4。现在,调用你的PowerShell文件:

命令行:C:\\用户\\管理\\文档\\的Visual Studio 2010\"\\Projects\\MvcApplication1\\MvcApplication1\\$c$cTemplates\\Scaffolders\\StevceScaffolders.AjaxGrid\\StevceScaffolders.AjaxGrid.ps1

Command Line:C:\Users\Admin\Documents\"Visual Studio 2010"\Projects\MvcApplication1\MvcApplication1\CodeTemplates\Scaffolders\StevceScaffolders.AjaxGrid\StevceScaffolders.AjaxGrid.ps1

(一定要引用有空格的文件夹,例如Visual Studio 2010的

(be sure to quote any folder that has spaces, eg. "Visual Studio 2010"

当然,我认为它会更好,如果他们的MS文档中提供了一些这方面的见解。

I certainly think it would have been better if MS provided some insight on this in their documentation.

这篇关于我怎样才能t4的脚手架从powershell.exe?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 19:30