I'm trying protobuf-net contract-first but for some reason I'm getting the following errors when I try to import user_session_2.proto because it depends on shared_1.proto. They are both in different directories. How do I deal with that issue?
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="protobuf-net" Version="3.1.25" />
<PackageReference Include="protobuf-net.BuildTools" Version="3.1.25">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="Protos\common\shared_1.proto" />
<AdditionalFiles Include="Protos\WebAPI\user_session_2.proto" />
</ItemGroup>
</Project>
Protos/common/shared_1.proto
syntax = "proto2";
package shared_1;
...
Protos/WebAPI/user_session_2.proto
syntax = "proto2";
package user_session_2;
import "common/shared_1.proto";
...
Related
I am typing in a cmd:
dotnet publish MyProject.Web.csproj --configuration Release --framework netcoreapp3.1 --runtime win-x64 --self-contained true --output '\bin\Release\netcoreapp3.1\publish'
And I am getting the following error.
C:\Program Files\dotnet\sdk\3.1.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(152,5): error MSB3094: "DestinationFiles" refers to 1 item(s), and "SourceFiles" refers to 428 item(s). They must have the same number of items. [C:\BuildAgent\work\7e7906b985af1c3\src\MyProject.Web\MyProject.Web.csproj]
Here is my MyProject.Web.csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<Authors>MyCompany Ltd</Authors>
<Company>MyCompany Ltd</Company>
<AssemblyVersion>1.0.0</AssemblyVersion>
<FileVersion>1.0.0</FileVersion>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac" Version="5.1.4" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MyProject.EntityFramework\MyProject.EntityFramework.csproj" />
<ProjectReference Include="..\MyProject\MyProject.csproj" />
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
I have seen similar solutions to stackoverflow but they are all for Visual Studio. I am running the command from a cmd directly.
Anyone knows what is causing that?
Every time I attempt to update 'Microsoft.Extensions.Primitives' it fails as follows:
GET https://api.nuget.org/v3/registration4-gz-semver2/microsoft.extensions.primitives/index.json
OK https://api.nuget.org/v3/registration4-gz-semver2/microsoft.extensions.primitives/index.json 142ms
Getting restore information for project /Users/developer/Source/WebApp-001/WebApp-001/WebApp-001.csproj
Running non-parallel restore.
Reading project file /Users/developer/Source/WebApp-001/WebApp-001/WebApp-001.csproj.
Persisting no-op dg to /Users/developer/Source/WebApp-001/WebApp-001/obj/WebApp-001.csproj.nuget.dgspec.json
Restoring packages for /Users/developer/Source/WebApp-001/WebApp-001/WebApp-001.csproj...
Restoring packages for .NETCoreApp,Version=v3.1...
GET https://api.nuget.org/v3-flatcontainer/microsoft.extensions.primitives/index.json
OK https://api.nuget.org/v3-flatcontainer/microsoft.extensions.primitives/index.json 3473ms
Resolving conflicts for .NETCoreApp,Version=v3.1...
Unable to find package Microsoft.Extensions.Primitives with version (>= 3.1.1)
- Found 36 version(s) in nuget.org [ Nearest version: 3.1.0 ]
Package restore failed. Rolling back package changes for 'WebApp-001'.
I'm using .NET Core 3.1 as my target framework on macOS using Visual Studio. I've tried updated from the terminal as well, no luck. This NuGet package and a few others are not able to be updated to version 3.1.1. They all appear to be "stuck" on version 3.1.0.
Maybe somebody has encountered this issue before? I don't understand why it is "[u]nable to find package Microsoft.Extensions.Primitives with version (>= 3.1.1)."
Copy of my .csproj file:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>WebApp_001</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'TheMidtownModel' ">
<StartAction>Project</StartAction>
<ApplicationURL>http://localhost:5002</ApplicationURL>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="3.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.RazorPages" Version="2.2.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.TagHelpers" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="2.2.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
<PackageReference Include="Sendgrid" Version="9.12.6" />
<PackageReference Include="React.AspNet" Version="5.1.2" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore" Version="3.3.0" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.linux-x64" Version="3.3.0" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64" Version="3.3.0" />
<PackageReference Include="JavaScriptEngineSwitcher.ChakraCore.Native.win-x64" Version="3.3.0" />
<PackageReference Include="JavaScriptEngineSwitcher.Extensions.MsDependencyInjection" Version="3.3.0" />
<PackageReference Include="Twilio.AspNet.Core" Version="5.33.1" />
<PackageReference Include="Twilio" Version="5.37.3" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.19" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
</ItemGroup>
<ItemGroup>
<Content Remove="wwwroot\css\bootstrap-grid.min.css" />
<Content Remove="wwwroot\css\bootstrap.min.css" />
<Content Remove="wwwroot\css\bootstrap.min.css.map" />
<Content Remove="wwwroot\js copy\__bootstrap.bundle.min.js" />
<Content Remove="wwwroot\js\bootstrap.js" />
<Content Remove="BackUpFiles\appsettings.Development.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Admin\" />
<Folder Include="Views\RoleAdmin\" />
<Folder Include="Views\Claims\" />
<Folder Include="Views\FileUpload\" />
<Folder Include="Authorization\" />
<Folder Include="Views\Shared\Layouts\" />
<Folder Include="Views\Shared\Partial\" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Migrations\20191216040205_SecondUpdateAlbumField.cs" />
<Compile Remove="Migrations\20191216040205_SecondUpdateAlbumField.Designer.cs" />
<Compile Remove="Migrations\20191216040329_ThirdUpdateAlbumField.cs" />
<Compile Remove="Migrations\20191216040329_ThirdUpdateAlbumField.Designer.cs" />
</ItemGroup>
</Project>
I'm trying to compile an uwp app but I get the following error:
Warning MCG : warning MCG0007: Unresolved P/Invoke method 'ntdll!RtlGetVersion' for method 'System.Int32 Microsoft.DotNet.PlatformAbstractions.Native.NativeMethods.Windows.RtlGetVersion(Microsoft.DotNet.PlatformAbstractions.Native.NativeMethods.Windows.RTL_OSVERSIONINFOEX)'. Calling this method would throw exception at runtime. Please make sure the P/Invoke either points to a Windows API allowed in UWP applications, or a native DLL that is part of the package. If for some reason your P/Invoke does not satisfy those requirements, please use [DllImport(ExactSpelling=true) to indicate that you understand the implications of using non-UWP APIs.
The thing is that I can't find the origin, is there a way to debug this issue? Or how could I find the library that is causing the issue?
UPDATE: I attach a sample project that throws the same compilation error. If anyone could take a look. I'll be very grateful.
Sample project
UPDATE 2: I have an UWP app that uses the following nuget packages:
This app uses 3 .netstandard libraries.
The UWP app contains the following references.
<PackageReference Include="AdaptiveCards">
<Version>1.2.4</Version>
</PackageReference>
<PackageReference Include="MailKit">
<Version>2.4.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.AppCenter">
<Version>2.6.4</Version>
</PackageReference>
<PackageReference Include="Microsoft.AppCenter.Analytics">
<Version>2.6.4</Version>
</PackageReference>
<PackageReference Include="Microsoft.AppCenter.Crashes">
<Version>2.6.4</Version>
</PackageReference>
<PackageReference Include="Microsoft.Azure.Storage.Blob">
<Version>11.1.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.9</Version>
</PackageReference>
<PackageReference Include="Microsoft.Services.Store.Engagement">
<Version>10.1901.28001</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Animations">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.Toolkit.Uwp.UI.Controls.DataGrid">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.UI.Xaml">
<Version>2.3.191211002</Version>
</PackageReference>
<PackageReference Include="Microsoft.Xaml.Behaviors.Uwp.Managed">
<Version>2.0.1</Version>
</PackageReference>
<PackageReference Include="MimeKit">
<Version>2.4.1</Version>
</PackageReference>
<PackageReference Include="MvvmLight">
<Version>5.4.1.1</Version>
</PackageReference>
<PackageReference Include="SQLitePCLRaw.bundle_green">
<Version>2.0.2</Version>
</PackageReference>
<PackageReference Include="SQLitePCLRaw.core">
<Version>2.0.2</Version>
</PackageReference>
<PackageReference Include="Win2D.uwp">
<Version>1.24.0</Version>
</PackageReference>
It uses 3 .netStandard libraries.
ServicesLibrary
<PackageReference Include="itext7" Version="7.1.9" />
<PackageReference Include="Microsoft.AppCenter" Version="2.6.4" />
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="2.6.4" />
<PackageReference Include="Microsoft.Azure.Storage.Blob" Version="11.1.1" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.7.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Portable.BouncyCastle" Version="1.8.5.2" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.7.0" />
<PackageReference Include="System.IO.FileSystem" Version="4.3.0" />
<PackageReference Include="System.IO.FileSystem.AccessControl" Version="4.7.0" />
<PackageReference Include="System.ServiceModel.Http" Version="4.7.0" />
DataLibrary
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Analyzers" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.1.0" />
<PackageReference Include="Z.EntityFramework.Extensions.EFCore" Version="3.0.31" />
<PackageReference Include="Z.EntityFramework.Plus.EFCore" Version="3.0.31" />
<PackageReference Include="Z.Expressions.Eval" Version="3.0.11" />
SigningLibrary
<PackageReference Include="BouncyCastle.NetCore" Version="1.8.5" />
<PackageReference Include="System.Security.AccessControl" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="4.7.0" />
<PackageReference Include="System.Security.Cryptography.Xml" Version="4.7.0" />
<PackageReference Include="System.Security.Permissions" Version="4.7.0" />
<PackageReference Include="System.Security.Principal.Windows" Version="4.7.0" />
The UWP references the ServicesLibrary and the DataLibrary, the ServicesLibrary references the SigningLibrary and the DataLibrary. That's the anatomy of the app that I'm trying to compile in release mode.
Thanks a lot for your help.
After all the suggestions, and trying to reproduce the compiler error. I find out that the Z.EntityFramework library was the one causing the issue. Looking at the logs all that I found was a reference to EntityFrameworkCore, related to the compiler error. But from that I started to remove libraries until I finally found the one that was causing the issue.
It's very hard and a bit frustrating finding the solution with such a cryptic message as MCG0007: Unresolved P/Invoke
Thanks for your help.
I have been trying to refer a .net core library project into my Azure function project to call one of the process defined in a .net core class library.
The .net core library project uses ILogger.
However, whenever I try to run a function I get the following error:
[29/11/2019 1:08:35 AM] The 'Function1' function is in error:
Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1'.
Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'log' to type
ILogger`1. Make sure the parameter Type is supported by the binding.
If you're using binding extensions (e.g. Azure Storage, ServiceBus,
Timers, etc.) make sure you've called the registration method for the
extension(s) in your startup code (e.g. builder.AddAzureStorage(),
builder.AddServiceBus(),
This is my code:
[FunctionName("Function1")]
public static void Run([TimerTrigger("0 */5 * * * *")] TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
// string templateFile = Path.Combine(context.FunctionAppDirectory, "Data", "HelloHttpOutputTemplate.txt");
Startup.Main(null).Wait();
}
I also confirmed that my .net core project as well as function project are referring a same version of ILogger:
'microsoft.extensions.logging.abstractions\3.0.0\lib\netstandard2.0'
If I remove a .net core library project reference from within function project then it works.
My function CS Project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<Content Include="..\Accounts.Console\appsettings.json" Link="appsettings.json" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.28" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Accounts.Console\Accounts.Console.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
My .net core Library project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<StartupObject></StartupObject>
<ApplicationIcon />
</PropertyGroup>
<ItemGroup>
<PackageReference Include="librdkafka.redist" Version="1.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.0.0" />
</ItemGroup>
</Project>
Update:
Have use .net core 3.0 now.
But still meet the same error:
This is my .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="librdkafka.redist" Version="1.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.28" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Solution:
Downgrading the version of Microsoft.Extensions.Http, Microsoft.Extensions.Logging.Console, Microsoft.Extensions.Logging.Debug and Microsoft.Extensions.Options from 3.0.0 to 2.2.0. Then error will be solved.
Original Answer:
I have reproduce your error:
Cause:
Assembly conflict. The key is your last four assembly references.
Solution:
Change them to 2.2.0. Things works fine on my side. Please have a try on your side and let me know if you have difficulties.
My .csproj file:
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="librdkafka.redist" Version="1.2.1" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
I have an ASP.Net Core application that includes the main project, two library projects, and a unit test project. When I run the unit tests, it complains:
[7/14/2019 9:55:38 PM Informational] ------ Discover test started ------
[7/14/2019 9:55:39 PM Warning] Test run will use DLL(s) built for framework .NETCoreApp,Version=v1.0 and platform X86. Following DLL(s) do not match framework/platform settings.
Indigo.UnitTests.dll is built for Framework 2.2 and Platform AnyCPU.
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.
[7/14/2019 9:55:41 PM Informational] ========== Discover test finished: 140 found (0:00:02.2274457) ==========
[7/14/2019 9:55:41 PM Informational] ------ Run test started ------
[7/14/2019 9:55:41 PM Warning] Test run will use DLL(s) built for framework .NETCoreApp,Version=v1.0 and platform X86. Following DLL(s) do not match framework/platform settings.
Indigo.UnitTests.dll is built for Framework 2.2 and Platform AnyCPU.
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.
The unit tests apparently run correctly. I've stared at my project configurations, and I've read the referenced article, but I can't figure out what it's complaining about. I've Googled the error message, but the stuff I've found doesn't seem to apply to my situation.
Here are my csproj files (FWIW):
The main project:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<UserSecretsId>xxx</UserSecretsId>
<ApplicationInsightsResourceId>xxx</ApplicationInsightsResourceId>
<ApplicationInsightsAnnotationResourceId>xxx</ApplicationInsightsAnnotationResourceId>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TypeScriptToolsVersion>3.4</TypeScriptToolsVersion>
</PropertyGroup>
<ItemGroup>
<DotnetPublishFiles Include="App_Data/**/*">
<DestinationRelativePath>App_Data/%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</DotnetPublishFiles>
</ItemGroup>
<ItemGroup>
<Content Remove="wwwroot\bundles\ajax.js" />
<Content Remove="wwwroot\bundles\captive-page.js" />
<Content Remove="wwwroot\bundles\captive-page.min.js" />
<Content Remove="wwwroot\bundles\datepicker.js" />
<Content Remove="wwwroot\bundles\datepicker.min.js" />
<Content Remove="wwwroot\bundles\ihi-validation-extensions.min.js" />
<Content Remove="wwwroot\bundles\jquery-validation.js" />
<Content Remove="wwwroot\bundles\main.js" />
<Content Remove="wwwroot\bundles\signalr.js" />
<Content Remove="wwwroot\bundles\signalr.min.js" />
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="wwwroot\bundles\ajax.js" />
<_ContentIncludedByDefault Remove="wwwroot\bundles\captive-page.js" />
<_ContentIncludedByDefault Remove="wwwroot\bundles\captive-page.min.js" />
<_ContentIncludedByDefault Remove="wwwroot\bundles\datepicker.js" />
<_ContentIncludedByDefault Remove="wwwroot\bundles\datepicker.min.js" />
<_ContentIncludedByDefault Remove="wwwroot\bundles\ihi-validation-extensions.min.js" />
<_ContentIncludedByDefault Remove="wwwroot\bundles\jquery-validation.js" />
<_ContentIncludedByDefault Remove="wwwroot\bundles\main.js" />
<_ContentIncludedByDefault Remove="wwwroot\bundles\main.min.css" />
<_ContentIncludedByDefault Remove="wwwroot\bundles\signalr.js" />
<_ContentIncludedByDefault Remove="wwwroot\bundles\signalr.min.js" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Flee" Version="1.2.2" />
<PackageReference Include="Humanizer" Version="2.6.2" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.7.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.5" />
<PackageReference Include="Microsoft.TypeScript.MSBuild" Version="3.5.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" PrivateAssets="All" />
<PackageReference Include="Neleus.DependencyInjection.Extensions" Version="1.0.0" />
<PackageReference Include="Sakura.AspNetCore.Mvc.PagedList" Version="2.0.12" />
<PackageReference Include="Sakura.AspNetCore.PagedList" Version="2.0.2" />
<PackageReference Include="Sakura.AspNetCore.PagedList.Async" Version="1.0.0" />
<PackageReference Include="Sendgrid" Version="9.11.0" />
<PackageReference Include="Twilio" Version="5.31.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ihi.Lib.Web\ihi.Lib.Web.csproj" />
<ProjectReference Include="..\..\ihi.Lib\ihi.Lib.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Areas\Identity\Services\" />
</ItemGroup>
<ItemGroup>
<None Include="wwwroot\bundles\ajax.js" />
<None Include="wwwroot\bundles\captive-page.js" />
<None Include="wwwroot\bundles\captive-page.min.js" />
<None Include="wwwroot\bundles\datepicker.js" />
<None Include="wwwroot\bundles\datepicker.min.js" />
<None Include="wwwroot\bundles\ihi-validation-extensions.min.js" />
<None Include="wwwroot\bundles\jquery-validation.js" />
<None Include="wwwroot\bundles\main.js" />
<None Include="wwwroot\bundles\signalr.js" />
<None Include="wwwroot\bundles\signalr.min.js" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Connected Services" />
</ItemGroup>
</Project>
The unit test project:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ihi.Lib.Web\ihi.Lib.Web.csproj" />
<ProjectReference Include="..\..\ihi.Lib\ihi.Lib.csproj" />
<ProjectReference Include="..\Indigo\Indigo.csproj" />
</ItemGroup>
</Project>
The first library project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="libphonenumber-csharp" Version="8.10.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="protobuf-net" Version="2.4.0" />
</ItemGroup>
</Project>
The second library project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Braintree" Version="4.12.0" />
<PackageReference Include="Markdig" Version="0.17.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.7.1" />
<PackageReference Include="Microsoft.AspNetCore.Html.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="protobuf-net" Version="2.4.0" />
<PackageReference Include="RestSharp" Version="106.6.10" />
<PackageReference Include="Sendgrid" Version="9.11.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ihi.Lib\ihi.Lib.csproj" />
</ItemGroup>
</Project>
This problem seems to be fixed in Visual Studio 16.2.2.
I just updated from Visual Studio 16.1.x to 16.3.3, and I was having similar issues. I normally run my tests using a ".runsettings" file, and I found I had to do two things:
Remove the <TargetFrameworkVersion> setting from the ".runsettings" file.
In the Build menu, run "Clean Solution". (Without this, test runner results would not show up in Test Explorer.)
I recently ran into this one on VS 2019 16.5.2 - turns out the project was updated to Microsoft.NET.Test.Sdk 16.5 - downgrading to 16.2 fixed my issue. I got v16.2 by successivley downgrading one version at a time. 16.4 and so on.
Seems Microsoft.NET.Test.Sdk 16.5 requires NET Core 3.0+