1

I am trying to build a .NET project that I have no idea how it works through MSbuild plugin in Jenkins.Anyhow, this targets framework 3.5 and that what I use in my build server. As I build I get the following error with no idea how to resolve..

 "c:\jenkins\workspace\Master.sln" (default target) (1) ->
"c:\jenkins\workspace\FactivaWebUI01-Fornax\UIVirtualServices\UIVirtualServices.csproj" (default target) (16) ->
(CoreCompile target) -> 
  CSP\Communicator\Authors\CommunicatorAuthorService.cs(36,78): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\CommunicatorAuthorService.cs(66,33): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\CommunicatorAuthorService.cs(67,29): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\CommunicatorAuthorService.cs(68,29): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\CommunicatorAuthorService.cs(69,28): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\CommunicatorAuthorService.cs(70,43): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\CommunicatorAuthorService.cs(71,41): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\CommunicatorAuthorService.cs(72,37): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\CommunicatorAuthorService.cs(73,56): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\CommunicatorAuthorService.cs(156,85): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\ICommunicatorAuthorService.cs(32,33): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\ICommunicatorAuthorService.cs(33,29): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\ICommunicatorAuthorService.cs(34,29): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\ICommunicatorAuthorService.cs(35,28): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\ICommunicatorAuthorService.cs(36,43): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\ICommunicatorAuthorService.cs(37,41): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\ICommunicatorAuthorService.cs(38,37): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Authors\ICommunicatorAuthorService.cs(39,56): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Charts\CommunicatorChartService.cs(54,68): error CS0241: Default parameter specifiers are not permitted
  CSP\Communicator\Charts\CommunicatorChartService.cs(54,109): error CS0241: Default parameter specifiers are not permitted

    184 Warning(s)
    20 Error(s)

the funny thing is that when I use visual studio 2013 to build the same project it builds just about fine.

csproj file :

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ProjectExtensions>
    <VisualStudio>
      <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
        <WebProjectProperties>
          <StartPageUrl>
          </StartPageUrl>
          <StartAction>CurrentPage</StartAction>
          <AspNetDebugging>True</AspNetDebugging>
          <SilverlightDebugging>False</SilverlightDebugging>
          <NativeDebugging>False</NativeDebugging>
          <SQLDebugging>False</SQLDebugging>
          <ExternalProgram>
          </ExternalProgram>
          <StartExternalURL>
          </StartExternalURL>
          <StartCmdLineArguments>
          </StartCmdLineArguments>
          <StartWorkingDirectory>
          </StartWorkingDirectory>
          <EnableENC>False</EnableENC>
          <AlwaysStartWebServerOnDebug>True</AlwaysStartWebServerOnDebug>
        </WebProjectProperties>
      </FlavorProperties>
    </VisualStudio>
  </ProjectExtensions>
</Project>

So as per suggestion, I try and build it with MsBuild 4.0 only to receive the following error:

(GenerateSerializationAssembliesForAllTypes target) -> 
  SGEN : error : An attempt was made to load an assembly with an incorrect format: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorlib.dll. [c:\jenkins\workspace\FactivaWebUI01-Fornax\MessageModel\MessageModel.csproj]

    129 Warning(s)
    1 Error(s)
Scooby
  • 3,371
  • 8
  • 44
  • 84

1 Answers1

2

I highly suspect that your .NET project does not, in fact, target the C# version included in .NET Framework 3.5 but rather C# 4.0, which is included in .NET Framework 4. See this question and this question, for example, where the same error is discussed. There is a good answer regarding the C# compiler versions and corresponding .NET Framework versions.

Can you provide the framework targeting information from your .NET project's .csproj project file to verify? It's an XML file and you should find the target framework information very near the top, for example:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <!-- Some elements omitted -->
    <TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>

UPDATE: Thank you for providing your .csproj file. That helps quite a bit. Notice in that file, the targeted .NET Framework version is 3.5 (<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>). Now, because you have C# 4.0 code in your project (such as the default parameters that you were getting warnings about), you must use the C# 4.0 compiler and update the target framework version to 4.0 (or higher). You can do this most safely via the project properties in Visual Studio. I wouldn't recommend editing the .csproj file by hand.

In short, your problem is due to the fact that using MSBuild 4.0 is not enough to compile the project against the 4.0 framework. It may use the newer compiler, which takes care of some (but not all!) of the language features, but it will not update the assemblies that your project uses.

Community
  • 1
  • 1
Lars Kemmann
  • 5,509
  • 3
  • 35
  • 67
  • Well, that certainly cleared up a few errors and warnings. :) Now, why on earth would it be trying to load the .NET 2.0 mscorlib? Can you please, instead of providing only a part of your `.csproj` file, provide the entire thing? Only remove any included source file references (compiled and content files) if you feel the need to, but **everything else is important** in this case. (And you did not provide the part which we really needed, the first time around.) We're looking for the project target framework version and references, to start with. – Lars Kemmann Aug 05 '14 at 20:11