使用VBC的命令行编译Settings.settings

发布于 2024-07-11 20:59:30 字数 1517 浏览 9 评论 0原文

对于我之前的一个问题,涉及 VBC 和 NAnt 与 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 中运行构建(调试详细程度设置为正常)时,生成的其中一行是:

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

How does one get the 上述 Generators to run from a command line, or is there a call that will generated the right temp files that are required to vbc.exe 能否正确运行命令字符串?

To an earlier question of mine, invovling VBC and NAnt with WinForms, I have since come up with a better way of stating this.

Within vbproj file, you have the following:

<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>

When one runs build from within Visual Studio (Debug Verbosity set to Normal), one of the lines produces is:

Target CoreCompile:
    C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Vbc.exe ...

Which includes all of the settings required for vbc.exe to run. However, taking that string from Visual Studio, and running it directly on the command line yields:

... 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

How does one get the above Generators to run from a command line, or is there a call somewhere that will generate the correct temp files that are needed for vbc.exe to run the command string correctly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

々眼睛长脚气 2024-07-18 20:59:30

在 Visual Studio 中查看构建字符串的问题在于,它实际上并未调用 vbc.exe 从 Visual Studio 进行构建。 Visual Studio 中的所有构建都使用内存编译器而不是命令行编译器进行(对于 C# 也是如此)。

看起来像 vbc.exe ... 的命令是一个生成的字符串,但实际上并未执行。 如果您想找到正确的字符串来构建项目,请从 Visual Studio 命令提示符运行以下代码。

msbuild /v:diag myproject.vbproj

这将生成一个 msbuild 日志文件(它会很长,所以我建议通过管道传输到一个文件)。 构建完成后,在该文件中搜索 vbc.exe。 它将具有构建项目所需的实际命令行。

The problem with looking at the build string within visual studio is that it's not actually calling vbc.exe to build from visual studio. All builds in visual studio happen with the in-memory compiler instead of the command line compiler (true for C# as well).

The command that looks like vbc.exe ... is a generated string that isn't actually executed. If you want to find out the correct string to build your project run the following code from a visual studio command prompt.

msbuild /v:diag myproject.vbproj

This will produce an msbuild log file (it will be quite long so I suggest piping to a file). Once the build is completed search for vbc.exe within that file. It will have the actual command line needed to build your project.

风吹雪碎 2024-07-18 20:59:30

今天我花了一些时间来研究这个问题。 我想知道如何让 vbc 编译器在“My”命名空间中正常工作的正确答案,但我设法使用 NAnt contrib (http://nantcontrib.sourceforge) 让我的 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 应用程序的第一次。

I spent a while working on this today. I'd like to know a proper answer as to how to get the vbc compiler to work properly in regard to the "My" namespace, but I managed to get my NAnt script working using NAnt contrib (http://nantcontrib.sourceforge.net/).

NAnt contrib allows you to build using the .NET msbuild, which at least allowed me to set up automated builds, notifications, etc. It does not give quite the granular control I would like, but it serves its purpose.

The reference on this task is:

http://nantcontrib.sourceforge.net/release/latest/help/tasks/msbuild.html

And the pertinent snippet from my build script:

<target name="build" depends="clean">
     <msbuild project="ProjectName.vbproj" />
</target>

I've used NAnt quite a bit for CS applications, but this is the first for a VB.NET application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文