SubSonic 3自动重新生成ActiveRecord类?

时间:2022-06-01 21:02:11

I have a SQLite database and SubSonic3, finally got a clue on how to generate the .cs from the .tt in Visual Studio. My stuff builds now.

我有一个SQLite数据库和SubSonic3,最后得到了如何从Visual Studio中的.tt生成.cs的线索。我的东西现在建立。

I can kick off MSBuild automatically to build my project, but I would like to add a pre-build event to regen the ActiveRecord.cs cleanly so any database changes end up there for future Unit tests.

我可以自动启动MSBuild来构建我的项目,但是我想添加一个预构建事件来干净地重新生成ActiveRecord.cs,这样任何数据库更改都会在未来的单元测试中结束。

How can I simulate the 'run external tool' in the Visual Studio GUI?

如何在Visual Studio GUI中模拟“运行外部工具”?

Thanks.

3 个解决方案

#1


You can run the TextTemplating tool from the command line:

您可以从命令行运行TextTemplating工具:

C:\Program Files\Common Files\Microsoft Shared\TextTemplating\1.2\TextTransform.exe "path/to/your/ttfile.tt" -out <outFileName>

Use TextTransform.exe /help for more command line arguments you can use.

使用TextTransform.exe / help可以使用更多命令行参数。

#2


At this time, the SubSonic's Settings.ttinclude file must be run from within the VisualStudio application, and can not be run from the command line. This is because Settings.ttinclude uses the project context to locate the App.config / Web.config file so that it can look up the connection string.

此时,SubSonic的Settings.ttinclude文件必须在VisualStudio应用程序中运行,并且无法从命令行运行。这是因为Settings.ttinclude使用项目上下文来查找App.config / Web.config文件,以便它可以查找连接字符串。

Attempting to run via command line using TextTransform.exe will result in the error:

尝试使用TextTransform.exe通过命令行运行将导致错误:

error : Running transformation: System.InvalidCastException: Unable to cast object of type 'Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost' to type 'System.IServiceProvider'.

错误:运行转换:System.InvalidCastException:无法将“Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost”类型的对象强制转换为“System.IServiceProvider”。

This stems from this method in Settings.ttinclude:

这源于Settings.ttinclude中的此方法:

public EnvDTE.Project GetCurrentProject()  {
    IServiceProvider _ServiceProvider = (IServiceProvider)Host;
    ...
}

#3


By hacking the Settings.ttinclude file, you can set up Subsonic to run from the command line.

通过黑客攻击Settings.ttinclude文件,您可以将Subsonic设置为从命令行运行。

Just modify it to set your connection string as the return value of GetConnectionString and taking out all other logic.

只需修改它以将连接字符串设置为GetConnectionString的返回值并取出所有其他逻辑。

#1


You can run the TextTemplating tool from the command line:

您可以从命令行运行TextTemplating工具:

C:\Program Files\Common Files\Microsoft Shared\TextTemplating\1.2\TextTransform.exe "path/to/your/ttfile.tt" -out <outFileName>

Use TextTransform.exe /help for more command line arguments you can use.

使用TextTransform.exe / help可以使用更多命令行参数。

#2


At this time, the SubSonic's Settings.ttinclude file must be run from within the VisualStudio application, and can not be run from the command line. This is because Settings.ttinclude uses the project context to locate the App.config / Web.config file so that it can look up the connection string.

此时,SubSonic的Settings.ttinclude文件必须在VisualStudio应用程序中运行,并且无法从命令行运行。这是因为Settings.ttinclude使用项目上下文来查找App.config / Web.config文件,以便它可以查找连接字符串。

Attempting to run via command line using TextTransform.exe will result in the error:

尝试使用TextTransform.exe通过命令行运行将导致错误:

error : Running transformation: System.InvalidCastException: Unable to cast object of type 'Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost' to type 'System.IServiceProvider'.

错误:运行转换:System.InvalidCastException:无法将“Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost”类型的对象强制转换为“System.IServiceProvider”。

This stems from this method in Settings.ttinclude:

这源于Settings.ttinclude中的此方法:

public EnvDTE.Project GetCurrentProject()  {
    IServiceProvider _ServiceProvider = (IServiceProvider)Host;
    ...
}

#3


By hacking the Settings.ttinclude file, you can set up Subsonic to run from the command line.

通过黑客攻击Settings.ttinclude文件,您可以将Subsonic设置为从命令行运行。

Just modify it to set your connection string as the return value of GetConnectionString and taking out all other logic.

只需修改它以将连接字符串设置为GetConnectionString的返回值并取出所有其他逻辑。