Entity Framkework migaration add failing - entity-framework

I am building a test app (learning) using .Net Core 2 and Angular 5.
From the root folder where csproj file is, in powerShell following execution is resulting in an error
Command
dotnet ef migrations add "Initial" -o "Data\Migrations"
Error
PS C:\Users\T460SU\Documents\Training\Learning-Examples\Api-Angular2018\NetCore2Angular5\TestMakerFreeApp\TestMakerFreeApp> dotnet ef migrations add "Initial" -o "Data\Migrations"
No executable found matching command "dotnet-ef"
After going through various posts, looks like i am missing Microsoft.EntityFrameworkCore.Tools.DotNet. When i try to install this package, it is resulting in the following error
PM> Install-Package Microsoft.EntityFrameworkCore.Tools.DotNet -Version 2.0.3
GET https://api.nuget.org/v3/registration3-gz-semver2/microsoft.entityframeworkcore.tools.dotnet/index.json
OK https://api.nuget.org/v3/registration3-gz-semver2/microsoft.entityframeworkcore.tools.dotnet/index.json 70ms
Restoring packages for C:\Users\T460SU\Documents\Training\Learning-Examples\Api-Angular2018\NetCore2Angular5\TestMakerFreeApp\TestMakerFreeApp\TestMakerFreeApp.csproj...
Install-Package : Detected package downgrade: Microsoft.NETCore.App from 2.0.7 to 2.0.0. Reference the package directly from the project to select a different version.
TestMakerFreeApp -> Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.3 -> Microsoft.NETCore.App (>= 2.0.7)
TestMakerFreeApp -> Microsoft.NETCore.App (>= 2.0.0)
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore.Tools.DotNet -Version 2 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Install-Package : Package 'Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.3' has a package type 'DotnetCliTool' that is not supported by project 'TestMakerFreeApp'.
At line:1 char:1
+ Install-Package Microsoft.EntityFrameworkCore.Tools.DotNet -Version 2 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Time Elapsed: 00:00:01.1203778
Here are the nuget packages currently installed
How can i fix this?
Update 1: csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<!-- Files not to publish (note that the 'dist' subfolders are re-added below) -->
<Content Remove="ClientApp\**" />
</ItemGroup>
<ItemGroup>
<None Remove="ClientApp\app\components\about\about.component.ts" />
<None Remove="ClientApp\app\components\login\login.component.ts" />
<None Remove="ClientApp\app\components\pagenotfound\pagenotfound.component.ts" />
<None Remove="ClientApp\app\components\quiz\quiz-list.component.ts" />
<None Remove="ClientApp\app\components\quiz\quiz.component.ts" />
<None Remove="ClientApp\app\interfaces\quiz.ts" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.0" />
</ItemGroup>
<ItemGroup>
<TypeScriptCompile Include="ClientApp\app\components\about\about.component.ts" />
<TypeScriptCompile Include="ClientApp\app\components\login\login.component.ts" />
<TypeScriptCompile Include="ClientApp\app\components\pagenotfound\pagenotfound.component.ts" />
<TypeScriptCompile Include="ClientApp\app\components\quiz\quiz-list.component.ts" />
<TypeScriptCompile Include="ClientApp\app\components\quiz\quiz.component.ts" />
<TypeScriptCompile Include="ClientApp\app\interfaces\quiz.ts" />
</ItemGroup>
<Target Name="DebugRunWebpack" BeforeTargets="Build" Condition=" '$(Configuration)' == 'Debug' And !Exists('wwwroot\dist') ">
<!-- Ensure Node.js is installed -->
<Exec Command="node --version" ContinueOnError="true">
<Output TaskParameter="ExitCode" PropertyName="ErrorCode" />
</Exec>
<Error Condition="'$(ErrorCode)' != '0'" Text="Node.js is required to build and run this project. To continue, please install Node.js from https://nodejs.org/, and then restart your command prompt or IDE." />
<!-- In development, the dist files won't exist on the first run or when cloning to
a different machine, so rebuild them if not already present. -->
<Message Importance="high" Text="Performing first-run Webpack build..." />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js" />
<Exec Command="node node_modules/webpack/bin/webpack.js" />
</Target>
<Target Name="PublishRunWebpack" AfterTargets="ComputeFilesToPublish">
<!-- As part of publishing, ensure the JS resources are freshly built in production mode -->
<Exec Command="npm install" />
<Exec Command="node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js --env.prod" />
<Exec Command="node node_modules/webpack/bin/webpack.js --env.prod" />
<!-- Include the newly-built files in the publish output -->
<ItemGroup>
<DistFiles Include="wwwroot\dist\**; ClientApp\dist\**" />
<ResolvedFileToPublish Include="#(DistFiles->'%(FullPath)')" Exclude="#(ResolvedFileToPublish)">
<RelativePath>%(DistFiles.Identity)</RelativePath>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
</Target>
</Project>

Could you please consolidate your .net core versions, so you can have a clean slate.
If you're using 2.0.x (or less), you need to add this to the project file (csproj) of the project housing your database logic
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.x" />
</ItemGroup>
Also, your add migration command needs to include your Startup project as well, if your database layer is a separate project. The dotnet ef command must be executed from the database project path, and it should look something like this:
dotnet ef --startup-project ..\Path\To\Startup migrations add Initial -c YourDatabaseContext
where startup project file also needs to contain the DotNetCliToolReference reference.
I didn't see you mentioning database contexts, but I'm sure you must have one.
If you switch to .net core version 2.1.0, everything stays the same, except that CLI tool is now part of the core entity package, so you can remove the CLI references from csproj files.
Hope it helps

Related

Azure DevOps build pipeline for Service Fabric Guest .Net Core 3.1 API exe fails on creating package

I have a .NET Core 3.1 API that I am attempting to deploy as a Guest Executable in Service Fabric using an Azure DevOps build pipeline. The platform for all projects/configurations is x64.
I have locally tested the API and also locally tested the API running as a guest executable within service fabric. I am able to build/rebuild the API and I am able to package the service fabric application.
In my build pipeline, I have the following steps shown in the picture below.
The Create Service Fabric Package is defined in the picture below
When the build pipeline runs, it always fails with the error:
##[error]AppraisalStatusUpdatesContainer\AppraisalStatusUpdatesContainer.sfproj(0,0): Error MSB4057: The target "Package" does not exist in the project.
I cannot find any documentation on what to do to solve this issue and have spent a couple of days trying. Does anyone know how to get this to work?
Edit 1
The sfproj is provided below
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.props" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" />
<PropertyGroup Label="Globals">
<ProjectGuid>ffefa7ed-cf72-4780-9910-816deed2ed4f</ProjectGuid>
<ProjectVersion>2.5</ProjectVersion>
<MinToolsVersion>1.5</MinToolsVersion>
<SupportedMSBuildNuGetPackageVersion>1.6.10</SupportedMSBuildNuGetPackageVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<None Include="ApplicationPackageRoot\ApplicationManifest.xml" />
<None Include="ApplicationParameters\Prod.xml" />
<None Include="ApplicationParameters\QA.xml" />
<None Include="ApplicationParameters\UAT.xml" />
<None Include="ApplicationParameters\Local.1Node.xml" />
<None Include="ApplicationParameters\Local.5Node.xml" />
<None Include="PublishProfiles\QA.xml" />
<None Include="PublishProfiles\UAT.xml" />
<None Include="PublishProfiles\Prod.xml" />
<None Include="PublishProfiles\Local.1Node.xml" />
<None Include="PublishProfiles\Local.5Node.xml" />
<None Include="Scripts\Deploy-FabricApplication.ps1" />
</ItemGroup>
<ItemGroup>
<Content Include="..\AppraisalStatusUpdates\bin\Release\netcoreapp3.1\publish\**\*.*">
<Link>ApplicationPackageRoot\AppraisalStatusUpdatesContainerPkg\Code\%(RecursiveDir)%(Filename)%(Extension)</Link>
</Content>
<Content Include="ApplicationPackageRoot\AppraisalStatusUpdatesContainerPkg\Config\Settings.xml" />
<Content Include="ApplicationPackageRoot\AppraisalStatusUpdatesContainerPkg\ServiceManifest.xml" />
<Content Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
<PropertyGroup>
<ApplicationProjectTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets</ApplicationProjectTargetsPath>
</PropertyGroup>
<Import Project="$(ApplicationProjectTargetsPath)" Condition="Exists('$(ApplicationProjectTargetsPath)')" />
<Import Project="..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets" Condition="Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" />
<Target Name="ValidateMSBuildFiles" BeforeTargets="PrepareForBuild">
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.props')" Text="Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.props' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
<Error Condition="!Exists('..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets')" Text="Unable to find the '..\packages\Microsoft.VisualStudio.Azure.Fabric.MSBuild.1.6.10\build\Microsoft.VisualStudio.Azure.Fabric.Application.targets' file. Please restore the 'Microsoft.VisualStudio.Azure.Fabric.MSBuild' Nuget package." />
</Target>
</Project>
Edit 2
#LeoLiu-MSFT, I have attempted the approach you mentioned. I am not getting the original error, but am now attempting to resolve the subsequent issues that resulted. Also, I am doing dotnet publish and dotnet test tasks before this step. It seems like the publish step is unnecessary except that it is needed for running the tests.
My msbuild step is now as follows
This results in the exception below:
##[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(777,5): Error : The OutputPath property is not set for project 'AppraisalStatusUpdatesContainer.sfproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Release' Platform='x64'. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn't exist for this project.
I have a custom Powershell script in my service fabric repositories for this.
It does a separate nuget restore for .sfproj.
The script restore-sf.ps1:
Push-Location $PSScriptRoot
$ProjectFolder = "..\src\YourProjectFolder"
$PackageFolder = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot "..\Packages"))
Push-Location $ProjectFolder
nuget restore YourServiceFabricProject.sfproj -PackagesDirectory $PackageFolder -MSBuildVersion 15
Pop-Location
Pop-Location
My folder structure:
├───Root
├───packages
├───src
├───YourProjectFolder
├───YourServiceFabricProject.sfproj
├───scripts
├───restore-sf.ps1
Depending on your folder structure, you'll need to change the paths in the script.
In the pipeline one of the first steps is to call the script, to restore the Microsoft.VisualStudio.Azure.Fabric.MSBuild package.
The script assumes nuget is available in the path.
Azure DevOps build pipeline for Service Fabric Guest .Net Core 3.1 API exe fails on creating package
According to the error:
MSB4057: The target "Package" does not exist in the project.
When you are using MSBuild for a solution of projects (.sln) with target Package, but not all projects have the Package task defined. That may be one of the reasons why you get this error.
To resolve this issue, we could add following custom target in the .sfproj file:
<Target Name="ForcePackageTarget" AfterTargets="Build" Condition="'$(ForcePackageTarget)' =='true'">
<CallTarget Targets="Package"/>
</Target>
Then add /p:ForcePackageTarget=true as an argument to the msbuild build task.
Please check this thread and this post for some more details.

Dotnet EF not recognized on multi sdk .net core

I have 2 dotnet core sdk installed on my computer (I have 2 project, one still run on 2.2 and the other running on 3.1)
When I run dotnet ef on my project (that still using v2.2) I got this error :
It was not possible to find any compatible framework version The
framework 'Microsoft.NETCore.App', version '3.1.1' was not found.
- The following frameworks were found:
2.2.8 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
3.1.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework
and/or SDK.
The specified framework can be found at:
- https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=3.1.1&arch=x64&rid=win10-x64
I have edit my global.json
{
"sdk": {
"version": "2.2.8",
"rollForward": "latestMajor"
}
}
but the error still appear everytime I need to run dotnet ef
dotnet run still okay ... it still using the correct sdk.
How to fix this ?
thank you
ps my csproj file :
my csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="jsreport.Client" Version="3.0.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.1" PrivateAssets="All" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="4.0.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.4" />
<PackageReference Include="MailKit" Version="2.0.6" />
</ItemGroup>
</Project>

Why is my Nuget-lib not available from .NetStandard 2.0?

I've created the Nuget "Uplink.NET" with the following Nuspec:
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd">
<metadata>
<id>uplink.NET</id>
<version>1.3.1</version>
<title>Connector to the storj-network</title>
<authors>TopperDEL,Storj Labs Inc.</authors>
<owners>TopperDEL,Storj Labs Inc.</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<projectUrl>https://github.com/TopperDEL/uplink.net</projectUrl>
<iconUrl>https://storj.io/press-kit/Storj-symbol.png</iconUrl>
<description>This library provides access to the secure and decentralised Storj-network. It allows you to:
- create and delete buckets
- upload and download files
It is - like Storj itself - open source and developed on GitHub.</description>
<releaseNotes>Initial release</releaseNotes>
<copyright>(c) 2019 TopperDEL, Storj Labs Inc.</copyright>
<tags>storj tardigrade storage decentralised secure bucket file xamarin android</tags>
<repository type="git" url="https://github.com/TopperDEL/uplink.net.git" />
<contentFiles>
<files include="uplink.NET\bin\release\netstandard2.0\storj_uplink.dll" buildAction="None" copyToOutput="true" flatten="true" />
</contentFiles>
</metadata>
<files>
<file src="uplink.NET.targets" target="build\uplink.NET.targets" />
<file src="uplink.NET.Droid\bin\Release\uplink.NET.Droid.dll" target="lib\MonoAndroid7.0\uplink.NET.Droid.dll" />
<file src="uplink.NET.Droid\bin\Release\uplink.NET.Droid.dll" target="lib\MonoAndroid7.1\uplink.NET.Droid.dll" />
<file src="uplink.NET.Droid\bin\Release\uplink.NET.Droid.dll" target="lib\MonoAndroid8.0\uplink.NET.Droid.dll" />
<file src="uplink.NET.Droid\bin\Release\uplink.NET.Droid.dll" target="lib\MonoAndroid8.1\uplink.NET.Droid.dll" />
<file src="uplink.NET.Droid\bin\Release\uplink.NET.Droid.dll" target="lib\MonoAndroid9.0\uplink.NET.Droid.dll" />
<file src="uplink.NET\bin\Release\netstandard2.0\uplink.NET.dll" target="lib\netstandard2.0\uplink.NET.dll" />
<file src="uplink.NET\bin\Release\netstandard2.0\uplink.NET.dll" target="netstandard2.0\uplink.NET.dll" />
<file src="uplink.NET\bin\Release\netstandard2.0\uplink.NET.dll" target="lib\uap10.0.16299\uplink.NET.dll" />
<file src="uplink.NET\storj_uplink.dll" target="storj_uplink.dll" />
</files>
</package>
I can add it to a NetStandard2.0 class library, but it gets Added as a PackageReference with the following entries:
<PackageReference Include="uplink.NET" Version="1.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
I now cannot access the objects within my lib. But the same Nuget is working with Xamarin.Android and UWP.
Can someone help with this?
Yes, when a package is a development dependency, as our NuGet docs say:
With PackageReference (NuGet 4.8+), this flag also means that it will
exclude compile-time assets from compilation.
A linked page further explains:
when package's developmentDependency is true, then set PrivateAssets
to All and ExcludeAssets to Compile on PackageReference item in
project, while:
Installing package through VS NuGet UI or PMC
Executing dotnet add
package command Migrating existing project from packages.config to
PackageReference
Even though developmentDependency is true, don't do anything treat it as normal
PackageReference, while:
Manually adding PackageReference item in project to add a package
Upgrading existing VS instance from previous version to latest (which started supporting developmentDependency)

.net core 2.1 EF Core reverse engineering errors VS 2017

Not having a great time with doing EF Core Reverse Engineering.
Latest error
The method or operation is not implemented.
Scaffold-DbContext "The method or operation is not implemented"
i get the same errors for both of these commands
Running this from Package Manager Console within VS 2017:
Scaffold-DbContext 'Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Chinook' Microsoft.EntityFrameworkCore.SqlServer
and from command prompt:
dotnet ef dbcontext scaffold "Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=Chinook" Microsoft.EntityFrameworkCore.SqlServer
Yes, I do alter them to have both my data source and database.
I get this error
Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=4.
0.3.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The located assembly's
manifest definition does not match the assembly reference. (Exception from HRES
ULT: 0x80131040)
I have gotten this before and after i upgraded to the .net core SDK 2.2.101
FYI, my csproj file looks like this
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>
</Project>
Between installing the EF power Tools and the Latest Core 2.2.x.x SDK I am now able to change my project to use dropdown change to the .net core 2.2 (it was previously only able to do 2.1.
Then with Nuget updates etc.. , it finally works!

Not able see test cases in Text Explorer for the .net core 2 based Test project

I have created a test project based on .Net Core 2 and wrote some NUnit test cases. After installing necessary NuGet packages i.e. NUnit3TestAdapter, I was able to see all test cases in "Test Explorer" and able to execute those. Now, when I looked into the project directory, I found that it's creating "obj" folder and some json files in it. So I tried to change the path of "obj" folder by modifying ".csproj" file. I provided some different path in the parameter "BaseIntermediateOutputPath" and that way, I was able to get rid of "obj" folder. The reason for providing different path was, I wanted to keep json files separate from source code.
However, after modifying that I am not able to see or execute any test cases from Test Explorer.
Is this a Microsoft bug?
Is any packages having dependency on "obj" folder?
P.S.
I am using "NUnit" and "NSubstitute" packages for my test project.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<TargetFramework>netcoreapp2.0</TargetFramework>
<OutputPath>..\..\build\$(Configuration)\UnitTests\</OutputPath>
<BaseIntermediateOutputPath>..\..\work\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<ItemGroup>
<PackageReference Include="Castle.Core" Version="4.1.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
<PackageReference Include="NSubstitute" Version="2.0.3" />
<PackageReference Include="NUnit" Version="3.8.1" />
<PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
</ItemGroup>
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<ItemGroup>
<ProjectReference Include="..\UtilityLibrary\UtilityLibrary.csproj" />
</ItemGroup>
</Project>
When .NET Core projects build, they do not copy all referenced files into the bin folder. When you add Microsoft.NET.Test.Sdk to your test project, one of the things it does is add an AssemblyResolve event handler which loads other dependent assemblies from a list of searchDirectories.
BaseIntermediateOutputPath not working was reported against the VSTest project and is an issue with MSBuild. The workaround is noted in the dotnet sdk repository. From that, you need to use Sdk imports in your csproj instead of the Sdk attribute on the Project element.
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath>obj\XXX\</BaseIntermediateOutputPath>
</PropertyGroup>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<!-- Body of project -->
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>