Msbuild: Win 10 Anniversary Update Caused MSBuild Break with StyleCop UsingTask

Created on 20 Aug 2016  路  4Comments  路  Source: dotnet/msbuild

After my machine updated to the Win 10 anniversary update, I've been getting this MSBuild/StyleCop Error across all the projects in my solution. I even nuked and re-pulled my TFS enlistment down and uninstalled/reinstalled StyleCop, but nothing worked:

Error 1 The "StyleCopTask" task could not be loaded from the assembly C:\code\myproject\Build\StyleCop\4.7\\StyleCop.dll. Could not load file or assembly 'Microsoft.Build.Utilities.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

It looks like the offending line is in the MSBuild StyleCop.targets file:

<UsingTask AssemblyFile="$(MSBuildExtensionsPath)\..\StyleCop 4.7\StyleCop.dll" TaskName="StyleCopTask"/>

It looks like something is mangling the path, if I follow what I expect to be the target, I see the StyleCop.dll file. I received the update on my other machine and it's still working fine (and has the exact same targets file and structure). Nothing else has changed.

How can I resolve this issue?

Most helpful comment

Thanks Rainer!

Yup missing:
image

Guessing it maybe got uninstalled during my upgrade to Win 10 Anniversary then (or something in the new environment changed the requirement to need it).

I checked the box (which I noticed my other machine did have already) and it worked right away! :)

All 4 comments

@hawkerm Do you have the .NET 3.5 optional feature installed? That's my first guess, since that assembly was part of the .NET Framework and your error mentions Version=3.5.0.0.

I'll check, maybe the upgrade installed it for me? Assuming I'll find out in Programs and Feature under Microsoft .NET Framework or under Windows Features?

The upgrade _should_ have preserved it if you had it installed before, but maybe that went wrong.

On my machine it's in "Turn Windows features on or off" and labeled ".NET Framework 3.5 (Includes .NET 2.0 and 3.0)". It should be checked for your scenario.

Thanks Rainer!

Yup missing:
image

Guessing it maybe got uninstalled during my upgrade to Win 10 Anniversary then (or something in the new environment changed the requirement to need it).

I checked the box (which I noticed my other machine did have already) and it worked right away! :)

Was this page helpful?
0 / 5 - 0 ratings