12

My company has TFS 2013.
I have a project using C# 6.0 features.
My team does not have direct access to the build server. VS2015 is not yet installed there but the folks that manage the server are looking to install the 2015 build tools.

In the mean time I have installed the Microsoft.Net.Compilers NuGet package as mentioned in answers to C# 6.0 TFS Builds and several other questions here.

Some projects in the solution already had it installed: (an Asp.Net MVC 5 project and a Web API project.)

When the solution is built, TFS uses the Rosyln compiler from the package for some projects and the default compiler for others.

  • I've removed and re-added the package.
  • I've tried switching between version 1.0.0, 1.1.0, and 1.3.2 of the package.
  • I've opened the .csproj files side by side to look for subtle differences.
  • I've created multiple solutions and multiple build definitions out of the same projects to see if some combination was causing the problem.
    • One of the projects always builds with the default compiler when part of one build and with the Roslyn compiler when build as part of another.

The two web projects never use the Roslyn compiler. There are 3 other libraries, one console application, and a hand-full of projects containing unit/integration tests. With the exception of the one project (one of the libraries) that behaves differently depending on which build it is in, all of the projects seem consistent in which compiler they use

What am I missing here? Why might TFS use the package compiler for some projects but not for others?

Sampling of build errors: Use of nameof:

SomeController.cs (53): The name 'nameof' does not exist in the current context

a static using:

RedactedTests.cs (5): Identifier expected; 'static' is a keyword
RedactedTests.cs (5): Expected class, delegate, enum, interface, or struct

null coalescing operator:

InterestingClassName.cs (40): Invalid expression term '.'
InterestingClassName.cs (40): Syntax error, ':' expected
InterestingClassName.cs (40): Invalid expression term '.'
InterestingClassName.cs (40): Syntax error, ':' expected

expression bodied property:

MyClass.cs (11): ; expected
MyClass.cs (11): Method must have a return type
MyClass.cs (11): Type expected
Community
  • 1
  • 1
Mr.Mindor
  • 4,079
  • 2
  • 19
  • 25
  • What's the detail error message you got in logs when the build failed? Moreover, If you run that C#6.0 project directly in VS on your local and on the build agent machine, will you get the same error message in both cases? – PatrickLu-MSFT Sep 01 '16 at 07:13
  • @Patrick-MSFT The error messages are syntax error messages and are different depending on which C#6.0 feature causes the failure, but I'll add some samples. Everything builds in VS2015 locally. My team does not have direct access to the build agent machine to run it there and the 2015 tools are not yet installed. – Mr.Mindor Sep 01 '16 at 13:21
  • Do you have the NuGet package installed on *every* project in the solution? -- It needs to be installed on each project. – BrainSlugs83 Apr 04 '17 at 16:17
  • @BrianSlugs83 We eventually got the folks in charge of the build server to install the 2015 tools and the problems was resolved. But yes at the time the NuGet package was installed on every project in the solution. – Mr.Mindor Apr 05 '17 at 13:13
  • Make sure you have installed latest MSbuild on build machine. Also make sure your project is configured to use c#6.0 or newer. Make sure that your build task use latest MSBuild or latest Visual Studio to build your project containing C#6.0 projects/solutions – Peter M. May 20 '19 at 17:49
  • @PeterM. The question is nearly 3 years old and the whole premise was that we (my team) _did not_ have access to do any installations on the build machine, so 'Make sure you have installed latest MSbuild on build machine." doesn't advance anything. – Mr.Mindor May 20 '19 at 17:57
  • @Mr.Mindor shame on me .. To be honest i did not check dates. but this question was at the top .. i will check next time. thanks for letting me know. – Peter M. May 20 '19 at 19:53
  • Environment variables? – Kit Aug 01 '23 at 21:53

1 Answers1

0

Maybe uses the version of the .sln file, be aware with this, if the solution is with Target Version.

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
MinimumVisualStudioVersion = 10.0.40219.1

Can you try to change this?

gatsby
  • 1,148
  • 11
  • 12
  • Double checked, all solutions have the same versions. and as indicated in the question, different projects in the same solution build with either the default compiler, or the nuget package compiler. if it was dependent on the solution version, it seems likely all projects would build using the nuget package compiler or all with the default. – Mr.Mindor Sep 13 '16 at 13:46