Missing Microsoft.Data.Tools.Schema.Sql.UnitTesting. Again
P

3

13

The bug is very old but MS didn't fix it so far.

I had a VS2015 solution (many projects, with main ASP.NET one) and I opened it in VS 2017.

Here is what I saw when I tried to build it:

So, I figured, okay, some referenced broke, I went into Project References, removed those two (...Sql.UnitTesting and ...Tools.Components), and tried to add them back. What did I saw? Of course, this:

The version is wrong, its 15.1.0.0 instead of previous 15.0.0.0 (for both DLLs). Big deal, you say, but it still doesn't compile:

It tells me that the versions are mismatched and I have to create some assembly-bindings in the web.config file. Which I did, first manually, then via the double-click on the warning, as it suggested. Nothing changed. I still can't get my project build.

Previous SO questions (Automatic reference to Microsoft.Data.Tools.Schema.Sql.UnitTesting, Where is the Microsoft.VisualStudio.TestTools.UnitTesting namespace on VS2010?) don't help much, I cannot remove SSDT component, as it breaks the loading of the web-project completely. And my project isn't any sort of SQL Testing project. It is just a regular ASP.NET 4 web app.

What can I do to fix this?

Pietra answered 17/6, 2017 at 11:2 Comment(0)
P
6

I have searched the project's file and found this:

<Import Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="'$(SQLDBExtensionsRefPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="'$(SQLDBExtensionsRefPath)' == ''" />

Then I searched the PC for Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets and I found some interesting results (clickable):

a screenshot of Windows search, searching for "Schema.Sql.UnitTesting.targets", which found three results , all three results with the filename "Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" in paths like C:\ProgramFiles (x86)<omitted>\VisualStudio\v14.0 , C:\ProgramFiles (x86)<omitted>\VisualStudio\v14.0

So, my previous studio, VS2015, had the v14 version of the file and the referenced were of 14 version as well, which is fine.

But the new VS2017's had references to the 15.0.0.0, according to the file contents:

the contents of the file "Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets, which includes an ItemGroup element, which includes a Reference element, and that Reference element has an  Include attribute and the value of that attribute includes "Version=15.0.0.0"

But the actual folder, which should contain these files has 15.1.0.0 version! And the binding redirects in my web.config file just doesn't work for some reason.

I see two solutions from here, change the Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets file so that it would contain 15.1.0.0 version, or replace 15.1.0.0 with 15.0.0.0 ones. I'll go with former now. Update soon.

Update

It still didn't help. No there are no build errors but the project build failed.

I also tried to remove those two XML lines from project's file and it kinda worked. Not so sure, because it now behaves even more weird.

It gave me a strange "missing ','" error on a line with somemethod(out Ticket ticket); (new C#7 feature), which is fine and doesn't have any errors, the error itself disappeared after 1 seconds after I saw it, but when I switched it back to C#6 way, it all finally built without problems. I'll try to run the project now.

Update

Yeah, just as I thought, dear Microsoft. Now it gives me this:

a screenshot of a StackTrace of an exception, the exception is of type LoaderExceptions and the exception message says "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information" -- the LoaderExceptions properties include four messages, the first message starts "Could not load file or assembly 'Microsoft.Data.Tools.Schema.Sql, Version=13.0.0.0, ....'"

So, there are some changes are yet to be made for me to finish my manual upgrade a simple webapp from vs2015 to vs2017.

Pietra answered 19/6, 2017 at 9:53 Comment(0)
K
12

enter image description here

Select NO and the Identity and Path should automatically resolve.

enter image description here

Kinsley answered 15/10, 2019 at 18:25 Comment(1)
This worked for me, but I have no idea why. Can someone explain?Arneson
P
6

I have searched the project's file and found this:

<Import Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="'$(SQLDBExtensionsRefPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="'$(SQLDBExtensionsRefPath)' == ''" />

Then I searched the PC for Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets and I found some interesting results (clickable):

a screenshot of Windows search, searching for "Schema.Sql.UnitTesting.targets", which found three results , all three results with the filename "Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" in paths like C:\ProgramFiles (x86)<omitted>\VisualStudio\v14.0 , C:\ProgramFiles (x86)<omitted>\VisualStudio\v14.0

So, my previous studio, VS2015, had the v14 version of the file and the referenced were of 14 version as well, which is fine.

But the new VS2017's had references to the 15.0.0.0, according to the file contents:

the contents of the file "Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets, which includes an ItemGroup element, which includes a Reference element, and that Reference element has an  Include attribute and the value of that attribute includes "Version=15.0.0.0"

But the actual folder, which should contain these files has 15.1.0.0 version! And the binding redirects in my web.config file just doesn't work for some reason.

I see two solutions from here, change the Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets file so that it would contain 15.1.0.0 version, or replace 15.1.0.0 with 15.0.0.0 ones. I'll go with former now. Update soon.

Update

It still didn't help. No there are no build errors but the project build failed.

I also tried to remove those two XML lines from project's file and it kinda worked. Not so sure, because it now behaves even more weird.

It gave me a strange "missing ','" error on a line with somemethod(out Ticket ticket); (new C#7 feature), which is fine and doesn't have any errors, the error itself disappeared after 1 seconds after I saw it, but when I switched it back to C#6 way, it all finally built without problems. I'll try to run the project now.

Update

Yeah, just as I thought, dear Microsoft. Now it gives me this:

a screenshot of a StackTrace of an exception, the exception is of type LoaderExceptions and the exception message says "Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information" -- the LoaderExceptions properties include four messages, the first message starts "Could not load file or assembly 'Microsoft.Data.Tools.Schema.Sql, Version=13.0.0.0, ....'"

So, there are some changes are yet to be made for me to finish my manual upgrade a simple webapp from vs2015 to vs2017.

Pietra answered 19/6, 2017 at 9:53 Comment(0)
I
6

In your test project file, remove this code:

<Import Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="'$(SQLDBExtensionsRefPath)' != ''" />
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="'$(SQLDBExtensionsRefPath)' == ''" />
<PropertyGroup>
    <SsdtUnitTestVersion>2.0</SsdtUnitTestVersion>
</PropertyGroup>

And replace it with this:

<ItemGroup Condition="$(VisualStudioVersion) == '15.0'">
    <Reference Include="Microsoft.Data.Tools.Schema.Sql, Version=13.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>$(SSDTPath)\Microsoft.Data.Tools.Schema.Sql.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTesting, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.dll</HintPath>
      <Private>True</Private>
    </Reference>
    <Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter.dll</HintPath>
      <Private>True</Private>
    </Reference>
  </ItemGroup>
<PropertyGroup>
    <SsdtUnitTestVersion>3.1</SsdtUnitTestVersion>
  </PropertyGroup>
 <Import Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' != ''" />
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' == ''" />

This is as per the official microsoft dev community help thread here.

Although for me it didn't work. Had to add propertygroup tags around ssdt version. You might want to keep it or remove it as per your project configurations.

Impatiens answered 12/4, 2019 at 9:27 Comment(2)
Your comment helped , but I use VS2019 as Development Env. Here I also had to exchange the last import Statements to match the new Visualstudio Version from 15.0 to 16.0 Then the error disappeared. Seems like changing VS Version may cause issues here and there.Immigrate
Glad it helped...and yes with each VS update, the SSDT version and other dependent assemblies change. This answer works with VS2017. For VS2019 you need to update the version numbers.Impatiens

© 2022 - 2024 — McMap. All rights reserved.