4
votes

I have a file name MVCWebUIComponent.csproj and I added below lines into my file

   <PropertyGroup>
        <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
        <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> </PropertyGroup>

    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

but it doesn't import the target package v10.0 into this path

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio

. I have v9.0 folder but I need to import package v10.0 into my visual studio 2017.what should i do?

1

1 Answers

2
votes

I have v9.0 folder but I need to import package v10.0 into my visual studio 2017.what should i do?

Not sure why you want import package v10.0 into your Visual Studio 2017. Since you want to import it into Visual Studio 2017, the value of $(MSBuildExtensionsPath32) should be the new location that is relative to the MSBuild directory:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild

So it doesn't import the target package v10.0 into the path C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio.

Besides, the import command:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

is a turned-off version (Condition="false") of the original line that allows for Visual Studio to still consider your project to be a valid Web Application Project (that's the trick that VS 2010 SP1 does itself). So, in general, the package v10.0 is not imported.

You can create a web application project, check the project file, you will find below code:

  <PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
  </PropertyGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

The import command <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> is the actual import, and latest line will be import when (Condition="false").

If import package v10.0 into my visual studio 2017 is your insistence, you just need to add something to the csproj to redirect MSBuildExtensionsPath:

<PropertyGroup>
    <MSBuildExtensionsPath32>C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio</MSBuildExtensionsPath32>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath32)\v10.0\WebApplications\Microsoft.WebApplication.targets" />

Note: Since you are have v9.0 folder, you should copy v10.0 from other machine.