Issue with nunit test runner - nunit

Unable to run nunit tests Microsoft Visual Studio 2022 v17.4.0
with
<package id="NUnit" version="3.13.3" targetFramework="net45" />
<package id="NUnit3TestAdapter" version="4.3.0" targetFramework="net45" />
throws
NUnit Adapter 4.3.0.0: Test discovery starting
Exception System.UnauthorizedAccessException, Exception thrown discovering tests in ***\Debug\Communication.dll
Access to the path 'C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\InternalTrace.11604.log' is denied.
How to solve it

Related

EF Core cannot install the Initial Migrations

These are the packages I have:
And this is my global.json file:
{
"sdk": {
"version": "3.1.101"
}
}
And this is my project file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.1" />
</ItemGroup>
</Project>
Now I am trying to run this command but I get an error. What am I missing?
dotnet ef migrations add Initial
Error I get:
A compatible installed .NET Core SDK for global.json version [3.1.101] from [C:\MyRepoz\SportsSln\SportsStore\global.json] was not found
Install the [3.1.101] .NET Core SDK or update [C:\MyRepoz\SportsSln\SportsStore\global.json] with an installed .NET Core SDK:
1.1.14 [C:\Program Files\dotnet\sdk]
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.508 [C:\Program Files\dotnet\sdk]
2.1.512 [C:\Program Files\dotnet\sdk]
2.1.801 [C:\Program Files\dotnet\sdk]
2.2.401 [C:\Program Files\dotnet\sdk]
3.1.301 [C:\Program Files\dotnet\sdk]
3.1.403 [C:\Program Files\dotnet\sdk]
OK the problem was that it specifically needs version 3.1.1 of .NET Core SDK.
So I went to their website and downloaded it and installed it.
Website is this: https://dotnet.microsoft.com/download/dotnet-core/3.1
Looks like dotnet is not recognised (you can verify it by typing dotnet --list-sdks, which should produce same error).
The solution should be to add env variable to PATH which points to the directory that contains SDKs. On Windows x64, this should be C:\Program Files\dotnet.
Also verify that C:\Program Files\dotnet\sdk\3.1.101 actually exists.

Android resource linking failed Flutter

I am running into this weird issue where I am getting this error.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
C:\Users\live\project_backup\build\file_picker\intermediates\library_manifest\debug\AndroidManifest.xml:9:5-15:15: AAPT: error: unexpected element <queries> found in <manifest>.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 15s
Weird thing is this happens after I upgrade file_picker package and persists even if I downgrade in pubspec.yaml again. But when I try run the project from the backup and replace lib folder with the one where this error occurred, it works perfectly. When this error occurs, plugin downgrade, flutter clean doesn't work. Why is this issue happening? When I click on the error link I am redirected to file_picker->intermediate->library_manifest->debug->Android Manifest.xml and the code there looks as below.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mr.flutter.plugin.filepicker" >
<uses-sdk android:minSdkVersion="16" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<queries>
<intent>
<action android:name="android.intent.action.GET_CONTENT" />
<data android:mimeType="*/*" />
</intent>
</queries>
Any suggestions on what is wrong and how to fix this?
I just found out the solution, queries is a new manifest element and require to use a new gralde android plugin.
so change to this version in build.gradle, this worked for me
classpath 'com.android.tools.build:gradle:4.1.0'
Also change gradle-wrapper version to 6.5 as it is required by 4.1.0 plugin
EDIT:
use this if and only if app does not work in release mode, otherwise use above method.
use file_picker version file_picker: 2.0.7 remember without ^ symbol. use android gradle plugin 3.5 only and don't migrate to 4.1.0.

Package Microsoft.EntityFrameworkCore.Sqlite 5.0.0-rc.1.20451.13 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86

I want to update my packages but I got some errors like this:
The error is:
Error NU1202 Package Microsoft.EntityFrameworkCore.Sqlite
5.0.0-rc.1.20451.13 is not compatible with net50 (.NETFramework,Version=v5.0) / win7-x86. Package
Microsoft.EntityFrameworkCore.Sqlite 5.0.0-rc.1.20451.13 supports:
netstandard2.1 (.NETStandard,Version=v2.1) API
E:...\API\API.csproj 1
API.csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="8.0.1" />
<PackageReference Include="CloudinaryDotNet" Version="1.11.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.7" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0-preview.8.20414.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0-preview.8.20407.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0-preview.8.20407.4" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.0-preview8" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.7.1" />
</ItemGroup>
</Project>
C:\WINDOWS\system32>dotnet --info .NET SDK (reflecting any
global.json):
Version: 5.0.100-rc.1.20452.10
Commit: 473d1b592e
Runtime Environment:
OS Name: Windows
OS Version: 10.0.17763
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program
Files\dotnet\sdk\5.0.100-rc.1.20452.10\
How can I solve this problem?
I had the same issue:
I updated my Visual Studio program from version 16.7 to 16.8 and now, problem solved!
I checked update manually
This solution is written in the comments of this question but I wanted to make it an answer to help others like me
You have to upgrade your nuget installer to latest version.
https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite/
https://www.nuget.org/downloads
If you are using Azure Devops, you can add a task step into your pipeline.
- task: UseDotNet#2
inputs:
packageType: sdk
version: 5.0.x
- task: NuGetToolInstaller#1
inputs:
versionSpec: ''
checkLatest: true
To develop any ASP.NET Core 5.0 app, you need Visual Studio 2019 version 16.8 or later, with the ASP.NET and web development workload installed.
https://learn.microsoft.com/en-us/dotnet/core/install/windows?tabs=net50
https://learn.microsoft.com/en-us/dotnet/architecture/grpc-for-wcf-developers/create-project
I had a global.json file in my project. After removing it problem was fixed because it mentioned a .net core 3.1 sdk.
Open .csproj file in notepad and change the target version from 3.1 to 2.1
From
<TargetFramework>netstandard5.0</TargetFramework>
To
<TargetFramework>netstandard2.1</TargetFramework>
Save file and close. Clean Solution then rebuild the solution.

Microsoft.AspNetCore.App vs Microsoft.NETCore.App publishing problem

I have a .NET core 2.2 application which I'm trying to publish to my web hosting but I'm getting a "500 - Internal Server Error" as a result.
I contacted support and they located the problem as being the following:
We enabled detailed error for your website and it is showing "Handler >"aspNetCore" has a bad module "AspNetCoreModuleV2" in its module list". It seems that you are using Microsoft.AspNetCore.App 2.2.1 for your website
application and this version is not installed on the server. Due to this website is not working.
On the server Microsoft.NETCore.App 2.2.1 is installed. So we would suggest you to re-deploy the application using .NetCore 2.2.1 and again check the website.
We only support .Net core runtimes installed on our shared hosting server. Re-deploy your application using the correct version to avoid any further issues. Please note that we do not support SCD (Self Contain Deployed application) on our shared server. We do support FDD (Framework Dependent Deployed application) only.
If I do a "dotnet --info" I can see that both .NETCore.App and AspNetCore.App are installed on my machine.
.NET Core SDKs installed:
2.2.103 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.1 [C:\Program
Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.1 [C:\Program > Files\dotnet\shared\Microsoft.NETCore.App]
My .csproj is referencing Microsoft.AspNetCore.App but it seems I cannot change this to Microsoft.NETCore.App.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App"/>
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.1"/>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.1"/>
</ItemGroup>
</Project>
Is there any way I can deploy this app to use Microsoft.NETCore.App so it works on the server?

dotnet restore with update in the new csproj/msbuild-based projects?

How do I actually update the new csproj-based project's Nuget packages to the latest ones when using Visual Studio Code?
This is what I have within the .csproj file:
<PackageReference Include="Microsoft.AspNetCore" Version="1.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.0.0" />
If I do dotnet restore it will only install the specified package versions.
There is no dotnet restore update or dotnet nuget update option available.
All of the above referenced Microsoft.AspNetCore.* packages have newer versions (1.1.0).
I would like to update the packages and have the references updated automatically in the same way we do this in Visual Studio.
Currently, VS Code does not have a built-in Nuget Manager tool. The only possible way is to edit .csproj file manually and update versions.
If regarding VS Code extensions, there is a Net Core Project Manager extension, that works pretty well.