Tvde1
Tvde1
CC#
Created by Tvde1 on 6/3/2024 in #help
dotnet test on Azure Devops has .NET 8 and requires .NET 6 and crashes?
I'm getting the following logs when attempting to run .NET tests:
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Testhost process for source(s) '/home/vsts/work/1/s/[redacted].Test/bin/Release/net6.0/win-x64/[redacted].Test.dll' exited with error: You must install or update .NET to run this application.
App: /home/vsts/work/1/s/CommonProjects/[redacted].Test/bin/Release/net6.0/win-x64/testhost.dll
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64)
.NET location: /opt/hostedtoolcache/dotnet/
The following frameworks were found:
8.0.6 at [/opt/hostedtoolcache/dotnet/shared/Microsoft.NETCore.App]
Learn more:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=linux-x64&os=ubuntu.22.04
. Please check the diagnostic logs for more information.
Results File: /home/vsts/work/_temp/_fv-az633-354_2024-05-31_14_52_14.trx
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Testhost process for source(s) '/home/vsts/work/1/s/[redacted].Test/bin/Release/net6.0/win-x64/[redacted].Test.dll' exited with error: You must install or update .NET to run this application.
App: /home/vsts/work/1/s/CommonProjects/[redacted].Test/bin/Release/net6.0/win-x64/testhost.dll
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '6.0.0' (x64)
.NET location: /opt/hostedtoolcache/dotnet/
The following frameworks were found:
8.0.6 at [/opt/hostedtoolcache/dotnet/shared/Microsoft.NETCore.App]
Learn more:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=linux-x64&os=ubuntu.22.04
. Please check the diagnostic logs for more information.
Results File: /home/vsts/work/_temp/_fv-az633-354_2024-05-31_14_52_14.trx
.NET 8 is installed using
steps:
- task: UseDotNet@2
displayName: 'Install .NET SDK'
inputs:
version: 8.x
performMultiLevelLookup: true
includePreviewVersions: false
steps:
- task: UseDotNet@2
displayName: 'Install .NET SDK'
inputs:
version: 8.x
performMultiLevelLookup: true
includePreviewVersions: false
and I'm running tests using
- task: DotNetCoreCLI@2
displayName: 'Test assemblies'
inputs:
command: 'test'
projects: '**/bin/**/*.Test.dll'
arguments: '-s .runsettings'
- task: DotNetCoreCLI@2
displayName: 'Test assemblies'
inputs:
command: 'test'
projects: '**/bin/**/*.Test.dll'
arguments: '-s .runsettings'
8 replies
CC#
Created by Tvde1 on 11/15/2023 in #help
Not mapping an EF Core DB-First enum property
I have scaffolded my Db Context. My entity has a
[Column("status")]
public string _status { get; set; }
[Column("status")]
public string _status { get; set; }
I am making a partial class which is:
public partial class Host
{
[NotMapped]
public HostStatus Status
{
get => Enum.Parse<HostStatus>(this._status);
set => this._status = value.ToString().ToLower();
}
}
public partial class Host
{
[NotMapped]
public HostStatus Status
{
get => Enum.Parse<HostStatus>(this._status);
set => this._status = value.ToString().ToLower();
}
}
Yet, when I do _context.Hosts.ToList(), it does attempt to select a column named "Status". How do I prevent this? The NotMapped attribute does not seem to be working.
23 replies
CC#
Created by Tvde1 on 6/20/2023 in #help
❔ ✅ Could not load file or assembly Microsoft.Bcl.AsyncInterfaces 7.0.0.0
I've upgaded the packages of about 100 csproj in multiple solutions and now each service logs:
An error occurred while writing to logger(s).

Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
An error occurred while writing to logger(s).

Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
When the /health endpoint is called. I can't tell which NuGet package is causing this. What's the recommended approach?
3 replies
CC#
Created by Tvde1 on 9/30/2022 in #help
Update SQL database rows with a dictionary [Answered]
I have the following SQL server table:
id | name | url
--------------
1 | John |
2 | Jane |
3 | Jack |
4 | Jill |
id | name | url
--------------
1 | John |
2 | Jane |
3 | Jack |
4 | Jill |
Where the URL column is empty for all rows. I have an excel sheet with an id and a url:
1 http://www.google.com
2 http://www.yahoo.com
3 http://www.bing.com
1 http://www.google.com
2 http://www.yahoo.com
3 http://www.bing.com
How can I create an UPDATE / MERGE statement where it will put all the correct URLs in my table? I know you can do an INSERT like
INSERT INTO Users
(Id, Url)
VALUES
(1, 'http://www.google.com'),
(2, 'http://www.yahoo.com'),
(3, 'http://www.bing.com')
INSERT INTO Users
(Id, Url)
VALUES
(1, 'http://www.google.com'),
(2, 'http://www.yahoo.com'),
(3, 'http://www.bing.com')
But I can't find whether you can do this with an UPDATE statement. You can do
UPDATE Users
SET Url = (
SELECT Url
FROM ???
WHERE Id = Users.Id
)
UPDATE Users
SET Url = (
SELECT Url
FROM ???
WHERE Id = Users.Id
)
But how do I get my data in that query?
10 replies
CC#
Created by Tvde1 on 9/19/2022 in #help
Use reflection to get type of abstract base class [Answered]
I have the following setup:
abstract class Formatter<T> { }
class StringFormatter : Formatter<string> { }
abstract class Formatter<T> { }
class StringFormatter : Formatter<string> { }
I want to use reflection to find out what kind of formatter a certain type is
Type type = typeof(StringFormatter);
string typeName = ??? // should be "string"
Type type = typeof(StringFormatter);
string typeName = ??? // should be "string"
How do I go about getting this?
7 replies
CC#
Created by Tvde1 on 9/19/2022 in #help
Query over multiple entities using the same interface [Answered]
I have a EF setup, where ~20 entities implement IArchivable This interface has a public
public Guid Id { get; }
public Guid IsArchived { get; set; }
public Guid Id { get; }
public Guid IsArchived { get; set; }
I wish to perform a query to find the entity with a certain id, and then another query to set the IsArchived property to false. Is this possible with EF? (something like _context.Set<IArchivable>().Where(...) Or should I loop through all types (using reflection) and build an IQueryable for each of them?
13 replies