none
MSBuild detecting wrong version of Visual Studio

    Question

  • I'm using VSTS to run an automated build process that invokes MSBuild. My solution was developed with Visual Studio Professional 2017 v15.4.5. When I execute the package, MSBuild throws the following error:

    MSReports\ITS\ITS.rptproj(70):MSReports\ITS\ITS.rptproj(70,11): Error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Reporting Services\Microsoft.ReportingServices.MSBuilder.targets" was not found. Also, tried to find "Reporting Services\Microsoft.ReportingServices.MSBuilder.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.

    So, MSBuild is searching under:
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Reporting Services (does not exist!)

    In reality, all my files are located under:
    C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Reporting Services (totally exists!)

    I don't have VS 2017 Enterprise installed, so I don't know why MSBuild is trying to search under that non-existent directory. I'm very new to working with MSBuild, so any guidance on how I can get MSBuild to recognize the correct path for my files would be appreciated.

    Thursday, November 30, 2017 4:25 PM

All replies

  • Hi pebenbow,

    Welcome to MSDN forum.

    You should use the hosted agent for VSTS, Visual Studio Enterprise is installed by default on machines in the VSTS Hosted VS2017 pool and we could not change VSTS to use Professional. See VSTS Hosted VS2017 image for detailed info.

    To resolve this issue, you can try to create a Private Agent on VSTS:

    https://docs.microsoft.com/en-us/vsts/build-release/actions/agents/v2-windows

    Alternatively, you can change your project file, to re-write the value $(MSBuildExtensionsPath).

    To accomplish this, unload your project. Then at the very end of the project </Project>, just before the end-tag, place below scripts:

      <PropertyGroup>
        <MSBuildExtensionsPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild</MSBuildExtensionsPath>
      </PropertyGroup>
    Hope this helps.


    MSDN Community Support Please remember to click Mark as Answer. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Friday, December 01, 2017 8:27 AM
  • Thanks for the suggestion. I haven't tried creating a Private Agent yet, but I did try modifying the rptproj file as you suggested because that seemed like the simplest and most straightforward approach. However, after making the edit, when attempting to reload the project file, Visual Studio threw this error at me:

    C:\Users\...\Source\Repos\SQL Server Reporting\MSReports\ITS\ITS.rptproj : error  : The '' Configuration already exists. Make sure that the product is installed properly.

    I can confirm that MSBuildExtensionsPath does not already exist in the rptproj file, but it is invoked at the very end of the file. Is this a matter of where precisely to place the script, or could that config setting already be set somewhere else?  

        <Report Include="Report Catalog.rdl" />
        <Report Include="Report Server Execution Log.rdl" />
      </ItemGroup>
      <Import Project="$(MSBuildExtensionsPath)\Reporting Services\Microsoft.ReportingServices.MSBuilder.targets" />
    </Project>


    • Edited by pebenbow Friday, December 01, 2017 3:43 PM updated wording
    Friday, December 01, 2017 3:27 PM
  • @pebenbow, please try this below:

      <PropertyGroup>
        <FullPath>$(Configuration)</FullPath>
        <MSBuildExtensionsPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild</MSBuildExtensionsPath>
      </PropertyGroup>

    Before add <FullPath>$(Configuration)</FullPath> this line in to the PropertyGroup, I got a error:

    C:\Users\Admin\Documents\Visual Studio 2017\Projects\Report Project2\Report Project2\Report Project2.rptproj : error  : There is an error in XML document (2, 2).

    not same as you. After add <FullPath>$(Configuration)</FullPath> into the PropertyGroup, it works fine on my side. Hope this can help you.

    If this not help you, please try to overwrite the $(MSBuildExtensionsPath) with full path:

    <Import Project="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Reporting Services\Microsoft.ReportingServices.MSBuilder.targets" />


    MSDN Community Support Please remember to click Mark as Answer. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Monday, December 04, 2017 8:28 AM
  • Thank you, Leo. I feel like we are getting closer. I was able to modify all of my rptproj files in the way you suggested, and they successfully reloaded into the solution. However, the build in VSTS still is failing.

    When I use the first approach:

      <PropertyGroup>
        <FullPath>$(Configuration)</FullPath>
        <MSBuildExtensionsPath>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild</MSBuildExtensionsPath>
      </PropertyGroup>

    I get this error message: 

    2017-12-06T13:11:20.2859084Z ##[error]MSReports\ITS\ITS.rptproj(69,11): Error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Reporting Services\Microsoft.ReportingServices.MSBuilder.targets" was not found. Also, tried to find "Reporting Services\Microsoft.ReportingServices.MSBuilder.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.exe.Config". Confirm that the path in the <Import> declaration is correct, and that the file exists on disk in one of the search paths.

    ----------

    And when I use the second approach:

    <Import Project="C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Reporting Services\Microsoft.ReportingServices.MSBuilder.targets" />

    I get this error message: 

    2017-12-06T13:25:02.9370215Z ##[error]MSReports\ITS\ITS.rptproj(70,2): Error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Reporting Services\Microsoft.ReportingServices.MSBuilder.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

    -----------

    I have confirmed that the file exists on my machine, but I don't know if this is perhaps a function of the build agent (I am still using Hosted VS2017).

    Wednesday, December 06, 2017 1:38 PM
  • @pebenbow, It works fine on the local without VSTS. And could not find a simple direct and effective method to resolve those error. And someone familiar with VSTS not suggest to use Professional Visual Studio on the hosted VS2017. So I suggest you can install the Enterprise Visual Studio on the hosted VS2017 or try to use Private Agent on VSTS.


    MSDN Community Support Please remember to click &quot;Mark as Answer&quot; the responses that resolved your issue, and to click &quot;Unmark as Answer&quot; if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, December 07, 2017 10:00 AM