4

I've added Microsoft.CodeDom.Providers.DotNetCompilerPlatform to my website in my Visual Studio 2015 solution to provide some C#6 features using Nuget. Everything runs and builds fine locally.

I've checked the code into TFS and created a build task for it. However I get the following error when this is built via TFS:

ShowcasePortal\web.config(20,0): Error ASPCONFIG: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located.

When executing the line:

Build:
  C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /localhost_15584 -p ShowcasePortal\ -u -f PrecompiledWeb\localhost_15584\ 

This is all hosted on visual studio online.

Is there anyway to get this build?

UPDATE:

I've noticed by default that the Bin folder is not checked in automatically. This has the Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll locally as well as a roslyn folder. I've added this to source control (not too sure if Roslyn folder needs to be added. Once added this works.

packages.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.2" targetFramework="net461" />
  <package id="Microsoft.Net.Compilers" version="1.3.2" targetFramework="net461" developmentDependency="true" />
</packages>

BUILD DEFINITON

The build definition looks like as follows:

Build Steps

This is just a bog standard build for a solution where I have not done anything special to make this build.

UPDATE 8th Dec

I added the bin\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll.refresh file to version control and kicked off a build which gave me the following error:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /localhost_15584 -p ShowcasePortal\ -u -f PrecompiledWeb\localhost_15584\ 
ASPNETCOMPILER(0,0): Error ASPRUNTIME: Could not find a part of the path 'C:\a\1\s\ShowcasePortal\bin\roslyn\csc.exe'.

Now the bin\Roslyn folder does exist on my machine locally. This is not checked in.

There is another package on nuget named Microsoft.CodeDom.Providers.DotNetCompilerPlatform.BinFix. I installed this and tried the cloud build. This did not work - it came up with the same error (could not find csc).

WORKING SOLUTION

When the package Microsoft.CodeDom.Providers.DotNetCompilerPlatform is added, it brings along the dependant Microsoft.Net.Compilers package. This adds the file Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll to the website Bin folder. There is also a Bin\Roslyn folder which is not added to the solution. This contains the various compiler binaries. Once the Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll is checked into version control aswell as ALL of the Bin\Roslyn files, the cloud server build will compile successfully.

Andez
  • 5,588
  • 20
  • 75
  • 116
  • 1
    You should be adding hear things as a NuGet package and not checking them directly into source control. – MrHinsh - Martin Hinshelwood Dec 01 '16 at 19:08
  • at least in my firm it happened because its was website and not a web application, meaning that one solution would be to go through the process of turning a website to a webapp. another scenario Microsoft forgot to check. – Yuval Perelman Dec 08 '16 at 13:58
  • I tried converting our monolithic web site to a web application following a few online guidelines. I gave up due to the amount of errors! – Andez Mar 01 '17 at 13:45

1 Answers1

1

The best solution for you just as MrHinsh mentioned you should use NuGet package to manage the dlls.

And in the build definition using Nuget Install task before your build task.

Related Nuget Package

CodeDOM Providers for .NET Compiler... 1.0.2

PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • I did add the Microsoft.CodeDom.Providers.DotNetCompilerPlatform using Nuget. This failed to build on the server. It wasn't until I checked the DLL in from the Bin folder it started working. I have updated the question. – Andez Dec 06 '16 at 08:55
  • If you have added the Nuget restore task in your build definition and still can't find the related dll. It seems NuGet not restoring packages on build. There's a lot of possibilities. http://stackoverflow.com/questions/20761322/nuget-not-restoring-packages-on-build Also double check the packages.config file. I'd like to say if check the bin folder in source control will solve the issue, then nuget package restore will do the same thing. – PatrickLu-MSFT Dec 06 '16 at 09:42
  • Curiously, I got the solution on a different computer and I get same error as build server: The CodeDom provider type "Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be located. That is with the empty Bin folder. Nuget package restore didn't seem to do anything with compilers. – Andez Dec 08 '16 at 08:31
  • 1
    Seems you are using VSTS not TFS. Otherwise you can directly copy the folders to the build server for a test. Anyway the solution you offer worked perfectly, it's enough. Thanks for the sharing. – PatrickLu-MSFT Dec 08 '16 at 10:06