Monday, November 4, 2013

Problem when upgrading Visual Studio 2010 Web Project to Visual Studio 2013

With the recent release of Visual Studio 2013, I decided to try and start upgrading some of my Visual Studio 2010 projects over to Visual Studio 2013.

I opened up a reasonably large solution that contained several different types of C# projects and the overall solution seemed to upgrade just fine.

However, when I built/re-built my solution, I noticed a very puzzling error message:

Well, it seemed to address the problem indirectly in a number of ways, but copying and pasting the code exactly as it appeared in the article did not seem to work for me!  However, the solution seemed correct nevertheless, so I tried a variation after more closely examining the MSBuild script since I knew that MSBuild 12.0 (which ships with Visual Studio 2013) changed various properties in MSBuild and that could be contributing to the continued error message.  In addition, I knew that the Publishing model changed from Visual Studio 2010 to Visual Studio 2013, so I removed both of the Microsoft.Web.Publishing elements.

Therefore, this was the final result of my Visual Studio 2013 change:
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

If you think you might still require preservation of the Microsoft.Web.Publishing.targets, you can alternatively simply enter an empty _CopyBinDeployableAssemblies target into your Visual Studio project file.  As it turns out, that also works!

I included the line just before the BeforeBuild event.  My resultant Visual Studio 2013 project file looked like this:

<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\Web\Microsoft.Web.Publishing.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.targets" Condition="false" />
<Target Name="_CopyBinDeployableAssemblies"></Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
<Target Name="AfterBuild">

1 comment:

  1. Thank you so much for this post! I was upgrading a huge solution from VS2010 to VS2015 and had an almost identical issue to the one you were having.

    Though my csproj file require some other imports, the take away for me here was to add the empty _CopyBinDeployableAssemblies target. That what was I was missing.

    Again, thanks a lot!