views:

890

answers:

1

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?

+3  A: 

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.

JaredPar
the command is actually "msbuild /v:diag myproject.vbproj >> log.txt"Not everyone is familiar with command line printing :)
Tom Anderson
@Tom, The >> will append though vs. create. With msbuild that will make the build log get big fast. It will also confuse users who search for the first instance of vbc.exe in the file (they'll always see the same one).
JaredPar
The vbc line in the output file appears to be the same.
MagicKat