none
[UWP] Error: "Cannot modify an evaluated object originating in an imported file" while updating the Microsoft.NET.Test.SDK NuGet package RRS feed

  • Question

  • Hi,

    I get the following error when I try to update Microsoft.NET.Test.SDK NuGet package to version 15.7.0:

    Cannot modify an evaluated object originating in an imported file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.Common.targets".   0 

    The file Microsoft.Windows.UI.Xaml.Common.targets exists and it contains the correct <ItemGroup> element.

    This is how to reproduce the problem:

    1. Repair or re-install Visual Studio (I repaired it). My version of VS is 15.6.5. This step is optional. I just wanted to make sure that my installation of VS is clean.
    2. Create a new Unit Test App (Universal Windows) project. Leave the default Target and Minimum versions (Target: Fall Creators Update Build 16299, Minimum: November Update Build 10586)
    3. Compile the project.
    4. Right-click on References and go to Manage NuGet Packages.
    5. Try to update the Microsoft.NET.Test.SDK NuGet package to version 15.7.0:

    6. Click "I Agree" in the prompt.
    7. VS generates the error and the NuGet package is not upgraded:

    Cannot modify an evaluated object originating in an imported file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.Common.targets"

    How to upgrade the Microsoft.NET.Test.SDK NuGet package?

    Thanks,

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com


    • Edited by ata6502 Thursday, April 5, 2018 1:26 PM
    Thursday, April 5, 2018 1:25 PM

Answers

  • I was able to fix this problem by opening my .csproj file in a text editor, add the following:

        <PackageReference Include="Microsoft.NET.Test.Sdk">
          <Version>15.6.0</Version>
        </PackageReference>

    Once I did this, I was able to upgrade the nuget package to the latest in the package manager.

    It's as if VS sees your unit test, assumes it references that package (even though it doesn't), and then fails when you try to update it.

    • Marked as answer by ata6502 Tuesday, April 10, 2018 12:22 PM
    Tuesday, April 10, 2018 1:53 AM

All replies

  • You can also uninstall the older one and try to install it again.

    You could go to this page and install it into your project as well.

     

     

    Regards,

    Fletcher


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" 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.


    Friday, April 6, 2018 3:16 AM
  • Hi Leszek,

    >>Cannot modify an evaluated object originating in an imported file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.Common.targets"

    Could you visit this targets file in your side? If you uninstall the 15.6.0 version firstly, and then install the latest version, how about the result?

    Sorry for that I couldn't repro it in my side, could you share a simple sample using one drive?

    Sincerely,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" 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.

    Friday, April 6, 2018 5:15 AM
    Moderator
  • Thanks Fletch and Jack.

    I have already tried to uninstall the older NuGet package. Visual Studio throws the same error:

    Cannot modify an evaluated object originating in an imported file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.Common.targets".

    Trying to install the new package using the NuGet console is no better:

    PM> Install-Package Microsoft.NET.Test.Sdk -Version 15.7.0
      CACHE https://api.nuget.org/v3/registration3-gz-semver2/microsoft.net.test.sdk/index.json
    Restoring packages for C:\Users\USER\Source\repos\UnitTestProject1\UnitTestProject1\UnitTestProject1.csproj...
    Install-Package : Cannot modify an evaluated object originating in an imported file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.Common.targets".
    At line:1 char:1
    + Install-Package Microsoft.NET.Test.Sdk -Version 15.7.0
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [Install-Package], Exception
        + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

    So it looks like I'm stuck. I really need to get these tests going. Is there any log I could look at to find out exactly what's going on? If you are not able to reproduce the problem, it seems it may be related to VS rather than to the project (although I've already repaired VS).

    This is a OneDrive link to the project I'm trying to update:

    https://1drv.ms/f/s!AoLvxm4hT-mqgdsJ_OBqEVCVKejRmA

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Friday, April 6, 2018 1:36 PM
  • I was able to fix this problem by opening my .csproj file in a text editor, add the following:

        <PackageReference Include="Microsoft.NET.Test.Sdk">
          <Version>15.6.0</Version>
        </PackageReference>

    Once I did this, I was able to upgrade the nuget package to the latest in the package manager.

    It's as if VS sees your unit test, assumes it references that package (even though it doesn't), and then fails when you try to update it.

    • Marked as answer by ata6502 Tuesday, April 10, 2018 12:22 PM
    Tuesday, April 10, 2018 1:53 AM
  • Thanks, Tim! That's solved the problem :)

    Leszek


    Wiki: wbswiki.com
    Website: www.wisenheimerbrainstorm.com

    Tuesday, April 10, 2018 12:22 PM