5

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?

GeralexGR
  • 2,973
  • 6
  • 24
  • 33
ZMAX
  • 149
  • 1
  • 12

1 Answers1

3

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.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • hi leo, thank u so much for ur reply.. :-) i'm jst trying to solve this problem. i am new to dot net & visual studio.. i saw some post regarding this & they stated to import v10.0. can u tell me how to solve this? i'm having trouble to solve it.running 32 bit MSBuild on a 64 bit machine – ZMAX Oct 20 '17 at 20:23
  • You mean you want to resolve the issue "The target “Package” does not exist in the project file named MVCWebUIComponent.csproj"? or other issue? If yes, what have you do and how to reproduce this issue? Besides, 32bit application can be used on the 64 bit machine. If your original issue is not about "import the target package v10.0", I suggest you can describe your issue with more detail info, what have you done, how did you repeoduce it and the error info with a new question. – Leo Liu Oct 23 '17 at 07:47
  • This saved my bacon while trying to web deploy (publish) with JetBrains Rider a classic ASP.NET web app to local folder. Thanks! – T H Feb 23 '23 at 22:00