For any developer who was using the previous Visual Studio 2017 RC build (26020.00) or previous they may encounter issues when upgrading to the latest release which was made available on the January 27, 2017 (build 26127.00).
Two issues affected me today which I have documented below on the fix, can be fixed easily but sometimes nice to have it pointed out. Obviously please backup and test in your environments !!
Error Duplicate 'Compile' items were included.
You may encounter the following error in your projects -
Error Duplicate 'Compile' items were included. The .NET SDK includes 'Compile' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultCompileItems' property to 'false' if you want to explicitly include them in your project file. The duplicate items were: 'xxxx.cs' xxx.yyy.zzz C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets
In previous versions of the project file you would have found the section within your project file that instructs the compiler to include the source files within the solution, these now seems to be included as default when included so the original entry now creates duplicate classes.
For example, previously you may have within your project.csproj file -
<ItemGroup> <Compile Include="**\*.cs" /> <EmbeddedResource Include="**\*.resx" /> </ItemGroup>
Simple remove the entire section (ItemGroup which includes the Compile and EmbeddedResource) above which will stop the duplicate error. Files will be included as default.
Warning A PackageReference for 'NETStandard.Library' was included in your project.
The second common error is that either one of the following libraries ( Microsoft.NETCore.App, NETStandard.Library and Microsoft.NET.Sdk ) are included in your project and will raise the error below.
Warning A PackageReference for 'NETStandard.Library' was included in your project. This package is implicitly referenced by the .NET SDK and you do not typically need to reference it from your project. For more information, see https://aka.ms/sdkimplicitrefs xxx.yyy.zzzz C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets
Simply edit the associated project.csproj file and rmeove the following line -
<PackageReference Include="NETStandard.Library" Version="1.6.1" />
The include is now implicit for .Net Core project files so does not need to be included in the project references any more.
As with any update it is worth visiting the Release Notes before apply the update and refer to for any other breaking change.
Comments welcome below