[Mono-dev] xbuild and a solution containing a vcxproj
nsalerno at securewatch24.com
Thu Aug 12 20:10:15 EDT 2010
Hello. I have an existing Visual Studio solution (VS 2010) file that I am porting to Mono. The whole solution does not have to build in Mono and I don't want to maintain two different build files. I have two platform configurations in the solution. The Win32 platform will build everything and the Mono platform will only build select projects. So far so good.
I started this effort when Mono 2.6.4 was the latest release. Since then I have upgraded to 2.6.7 because the 2.6.4 runtime would crash (SIGSEGV) when executing the code I ported to Mono. So far so good (the assemblies execute properly with the 2.6.7 runtime). I have a problem with the 2.6.7 xbuild where it is throwing a runtime exception of type System.FormatException. This happens because a project in the solution has a reference to another project that does not exist in the solution. Specifically, a csproj file contains a <ProjectReference> element. This element contains a GUID (via the <Project> child element) and this GUID does not exist in the solution file. Here is the stack trace from the build:
Unhandled Exception: System.FormatException: Input string was not in a correct format.
at System.String.ParseFormatSpecifier (System.String str, System.Int32& ptr, System.Int32& n, System.Int32& width, System.Boolean& left_align, System.String& format) [0x00000] in <filename unknown>:0
at System.String.FormatHelper (System.Text.StringBuilder result, IFormatProvider provider, System.String format, System.Object args) [0x00000] in <filename unknown>:0
at System.String.Format (IFormatProvider provider, System.String format, System.Object args) [0x00000] in <filename unknown>:0
at System.String.Format (System.String format, System.Object args) [0x00000] in <filename unknown>:0
at Microsoft.Build.BuildEngine.Project.LogWarning (System.String filename, System.String message, System.Object messageArgs) [0x00000] in <filename unknown>:0
at Microsoft.Build.BuildEngine.Project+<Load>c__AnonStorey10.<>m__1 (Int32 errorNumber, System.String message) [0x00000] in <filename unknown>:0
at Mono.XBuild.CommandLine.SolutionParser.ParseSolution (System.String file, Microsoft.Build.BuildEngine.Project p, Mono.XBuild.CommandLine.RaiseWarningHandler RaiseWarning) [0x00000] in <filename unknown>:0
at Microsoft.Build.BuildEngine.Project.Load (System.String projectFileName, ProjectLoadSettings settings) [0x00000] in <filename unknown>:0
at Microsoft.Build.BuildEngine.Project.Load (System.String projectFileName) [0x00000] in <filename unknown>:0
at Mono.XBuild.CommandLine.MainClass.Execute () [0x00000] in <filename unknown>:0
So, what project am I missing? What typo may exist? Well, I have found that my solution contains a single C++/CLI project (vcxproj). The output of xbuild shows the project being ignored (warning : Ignoring vcproj 'Data.Manager'). What happens then is that a few C# projects have a reference to this project and xbuild throws the System.FormatException object, which I have come to interpret as "hey, you say A depends on B but B doesn't exist in the solution." This seems like a bug because even if xbuild wants nothing to do with the vcxproj (and that is fine) it should still be aware of its existence (via the project's GUID that it has read). This behavior does not happen with the 2.6.4 xbuild. Note that I am not trying to build these particular projects in Mono and they are not enabled in the "Mono" platform configuration of my solution.
I have noticed similar warnings in the 2.6.4 version of xbuild. However, this did not stop the build nor throw exceptions. I was able to build my selected projects with 2.6.4 and now I cannot build anything in 2.6.7 because of the thrown exception. Right now I have a complete 2.6.4 system with a 2.6.7 CLR and C# compiler dropped in place. I imagine there are consequences with that setup and would like to use a homogenous 2.6.7 installation. Is there anything I can do to work around this? Would it be safer to drop a 2.6.4 xbuild (and its version of MSBuild target files) in a complete 2.6.7 installation?
I am running openSUSE 11.2 and have installed Mono from RPM packages. Thanks.
More information about the Mono-devel-list