C # object initializers and compiler error v2.0

I am having a problem setting up one of my projects in TeamCity (v4.0), especially when it comes to using Object Initializers.

The project builds fine fine, however it seems that TeamCity is converting the build file to something it likes (some MSBuild mutations) and when it comes to compiling the code for the solution part it intercepts when it sees the Object Initializer.

In particular, errors:

[11:16:21]: ErrorView.xaml.cs(22, 187): error CS1026: ) expected
[11:16:21]: ErrorView.xaml.cs(22, 208): error CS0116: A namespace does not directly contain members such as fields or methods
[11:16:21]: ErrorView.xaml.cs(27, 16): error CS1518: Expected class, delegate, enum, interface, or struct
[11:16:21]: ErrorView.xaml.cs(35, 16): error CS1518: Expected class, delegate, enum, interface, or struct
[11:16:21]: ErrorView.xaml.cs(46, 91): error CS1031: Type expected
[11:16:21]: ErrorView.xaml.cs(46, 119): error CS0116: A namespace does not directly contain members such as fields or methods
[11:16:21]: ErrorView.xaml.cs(48, 17): error CS1022: Type or namespace definition, or end-of-file expected

      

When I look at this further, it looks like the problem is with converting the assembly file to TeamCity format using CSC from v2.0 frames directory.

Is it possible to compile the code using object initializers (.NET 3.0 feature) with the .NET 2.0 compiler (I would guess not, although maybe something is missing), and if not, does anyone know a way to force it to should I use the 3.0 compiler (if it exists) or the 3.5 compiler?

For interested users, the CSC command is executed:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE 
/reference:..\..\..\build\blah.Logging.dll /reference:..\..\..\build\blah.Presentation.Interfaces.dll 
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.VisualBasic.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll" 
/reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll" 
/reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.Luna.dll" 
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Design.dll 
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll 
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll 
/reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll 
/reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\UIAutomationProvider.dll"
/reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll" /debug+ /debug:full /filealign:512 
/keyfile:..\..\..\resources\blah.snk /optimize- /out:obj\Debug\blah.dll 
/resource:obj\Debug\blah.UserInterface.Properties.Resources.resources
/resource:obj\Debug\blah.UserInterface.blah.exe.license /target:library 
/win32icon:blah.ico SignalStrengthIndicator.xaml.cs TrayNotifier.xaml.cs ConnectedView.xaml.cs ConnectionProgressView.xaml.cs NetworkPasswordView.xaml.cs 
TrayProgress.xaml.cs NetworkConnectionView.xaml.cs ClassFiles\NetworkTypeConverter.cs 
ClassFiles\SecurityImageConverter.cs ClassFiles\SecurityTooltipConverter.cs 
ClassFiles\SignalStrengthTooltipConverter.cs ClassFiles\SignalVisibilityConverter.cs 
ClassFiles\SynchronizedObservableCollection.cs ConnectionOption.xaml.cs 
DisconnectionProgressView.xaml.cs ErrorView.xaml.cs ..\..\..\config\assemblyversion.cs 
Properties\Resources.Designer.cs Properties\Settings.Designer.cs

      

Thank!

Update: I partially (read: I'm not happy) fixed the issue by changing the build runner from Nant to the command runner - this just ran the Nant build file as it was intended without any manipulation, although the level of feedback is different. Any other suggestions would be appreciated.

0


source to share


2 answers


Are you using sln2005? This will use 2.0 csc. Check your build config and change it to sln2008 runner (see http://www.jetbrains.net/confluence/display/TCD4/3.Build+Runners ). This should use the 3.5 compiler.

If you are using the MSBuild runner http://www.jetbrains.net/confluence/display/TCD4/MSBuild make sure you set the version number to 3.5 on the config page.

Edit: after NAnt check See http://www.jetbrains.net/confluence/display/TCD4/NAnt_



where it says "By default the NAnt msbuild task uses MSBuild 2.0 (from Microsoft .NET Framework 2.0), however you can use MSBuild 3.5 (from Microsoft .NET Framework 3.5) if you add the teamcity_dotnet_use_msbuild_v35 property to true for your msbuild task in NAnt script. For example: "

<msbuild project="SimpleEcho.v35.proj">
   <!-- this property enables MSBuild 3.5 -->
   <property name="teamcity_dotnet_use_msbuild_v35" value="true"/>
   ...
 </msbuild>

      

+3


source


For a NAnt script, one can simply define the teamcity_dotnet_use_msbuild_v35 system property in the build config settings ( http://www.jetbrains.net/confluence/display/TCD4/6.Properties+and+environment+variables ) to force it to run msbuild 3.5.



On the other hand, if the NAnt target framework is installed in net-3.5 (NAnt 0.86 beta 1 only) msbuild should be taken from the .NET 3.5 folder.

0


source







All Articles