To an earlier question of mine, invovling VBC and NAnt with WinForms,我想出了一种更好的方式来表达这一点。
在vbproj文件中,您具有以下内容:
<ItemGroup>
<None Include="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput>
</Content>
</ItemGroup>当用户从Visual Studio中运行build (Debug Verbosity设置为Normal)时,其中一行代码为:
Target CoreCompile:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Vbc.exe ...其中包括运行vbc.exe所需的所有设置。但是,从Visual Studio中提取该字符串,并直接在命令行上运行它会产生以下结果:
... My Project\Settings.Designer.vb(67) : error BC30002: Type 'My.MySettings' is not defined.
Friend ReadOnly Property Settings() As Global.My.MySettings
...\My Project\Settings.Designer.vb(69) : error BC30456: 'My' is not a member of '<Default>'.
Return Global.My.MySettings.Default如何从命令行运行上述生成器,或者是否有某个调用将生成vbc.exe正确运行命令字符串所需的正确临时文件?
发布于 2009-01-07 03:11:42
在visual studio中查看build字符串的问题在于,它实际上并没有调用vbc.exe来从visual studio中生成。visual studio中的所有生成都使用内存中的编译器,而不是命令行编译器(对于C#也是如此)。
看起来像vbc.exe的命令...是一个生成的字符串,实际上并没有执行。如果要查找生成项目所需的正确字符串,请从visual studio命令提示符运行下面的代码。
msbuild /v:diag myproject.vbproj
这将产生一个msbuild日志文件(它会很长,所以我建议通过管道连接到一个文件)。构建完成后,在该文件中搜索vbc.exe。它将包含构建项目所需的实际命令行。
发布于 2011-01-28 07:00:25
我今天花了一段时间在这上面。我想知道关于如何让vbc编译器在" my“命名空间中正常工作的正确答案,但是我设法使用NAnt contrib (http://nantcontrib.sourceforge.net/)让我的NAnt脚本工作。
NAnt contrib允许您使用.NET msbuild进行构建,这至少允许我设置自动构建、通知等。它没有提供我想要的粒度控制,但它达到了它的目的。
此任务的参考资料为:
http://nantcontrib.sourceforge.net/release/latest/help/tasks/msbuild.html
以及我的构建脚本中的相关代码片段:
<target name="build" depends="clean">
<msbuild project="ProjectName.vbproj" />
</target>我在CS应用程序中使用过很多次NAnt,但对于VB.NET应用程序来说,这还是第一次。
https://stackoverflow.com/questions/418878
复制相似问题