I'm trying to connect my azure function to my azure sql database. When trying connection.open() it gives the following error.
Executed 'ClientID2' (Failed, Id=22ad8465-45f5-4fff-ba90-f0ff7d0ee465,
Duration=5895ms) [2021-11-25T10:49:57.575Z] System.Private.CoreLib:
Exception while executing function: ClientID2.
Microsoft.Data.SqlClient: The type initializer for
'Microsoft.Data.SqlClient.TdsParser' threw an exception.
Microsoft.Data.SqlClient: Could not load file or assembly
'System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a'.
The connection itself runs on .net 5.0 framework, but not in .net core 3.1 .
[FunctionName("ClientID2")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = null)] HttpRequest req, ILogger log)
{
string requestBody = string.Empty;
try
{
log.LogInformation("Function process");
using (SqlConnection connection = new SqlConnection(Environment.GetEnvironmentVariable("Connection_Database")))
{
connection.Open();
Packages installed
Can anyone point me in the right direction?
Best regards
EDIT:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<RootNamespace>Client_ID</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.30" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="6.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Local.Settings.Json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"Connection_Database": Connection string from azure sql database
}
}
I figured it out, but not sure if it is the correct way.
Had to put the System.Text.Encoding.CodePages.dll and System.Runtime.CompilerServices.Unsafe.dll directly in bin folder of project.
Next, according to this answer
I added to the .csproj the following
<ItemGroup>
<FunctionsPreservedDependencies Include="System.Text.Encoding.CodePages.dll" />
<FunctionsPreservedDependencies Include="System.Runtime.CompilerServices.Unsafe.dll" />
</ItemGroup>
And then it worked
Related
I am trying to get some values from the appsettings.json. But whatever I try with the AdditionalTextsProvider doesn't work. Here is my code
IncrementalValuesProvider<AdditionalText> textFiles = context.AdditionalTextsProvider.Where(static file => file.Path.Contains("appsettings.json")); // tried many things here, like EndsWith(".json") etc..
IncrementalValuesProvider<(string name, string content)> namesAndContents = textFiles.Select((text, cancellationToken) => (name: Path.GetFileNameWithoutExtension(text.Path), content: text.GetText(cancellationToken)!.ToString()));
context.RegisterSourceOutput(namesAndContents, (spc, nameAndContent) =>
{
nameAndContent.content; //always empty
nameAndContent.name; //always empty
});
From the other hand, when I implement the ISourceGenerator (same solution, same projects) this line of code just works!
var file = context.AdditionalFiles.FirstOrDefault(x => x.Path.Contains("appsettings.json"));
The project which is referencing the code generator:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Scrutor" Version="4.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\myproject\myproject.csproj" />
<ProjectReference Include="..\myproject.EFCore\myproject.EFCore.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="appsettings.json" />
</ItemGroup>
</Project>
Code generator project :
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<LangVersion>latest</LangVersion>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> <!-- Generates a package at build -->
<IncludeBuildOutput>false</IncludeBuildOutput> <!-- Do not include the generator as a lib dependency -->
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.1.0" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<!-- Generator dependencies -->
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" GeneratePathProperty="true" PrivateAssets="all" />
</ItemGroup>
<PropertyGroup> <GetTargetPathDependsOn>$(GetTargetPathDependsOn);GetDependencyTargetPaths</GetTargetPathDependsOn>
</PropertyGroup>
<Target Name="GetDependencyTargetPaths">
<ItemGroup>
<TargetPathWithTargetPlatformMoniker Include="$(PKGNewtonsoft_Json)\lib\netstandard2.0\Newtonsoft.Json.dll" IncludeRuntimeDependency="false" />
</ItemGroup>
</Target>
<ItemGroup>
<!-- Package the generator in the analyzer directory of the nuget package -->
<None Include="$(OutputPath)\$(AssemblyName).dll" Pack="true" PackagePath="analyzers/dotnet/cs" Visible="false" />
<!-- Package the props file -->
</ItemGroup>
</Project>
If you combine the additional text provider with the compilation it works for me (inspired by this great post):
public void Initialize(IncrementalGeneratorInitializationContext context)
{
var files = context.AdditionalTextsProvider
.Where(a => a.Path.EndsWith("appsettings.json"))
.Select((a, c) => (Path.GetFileNameWithoutExtension(a.Path), a.GetText(c)!.ToString()));
var compilationAndFiles = context.CompilationProvider.Combine(files.Collect());
context.RegisterSourceOutput(compilationAndFiles, (productionContext, sourceContext) => Generate(productionContext, sourceContext));
}
void Generate(SourceProductionContext context, (Compilation compilation, ImmutableArray<(string, string)> files) compilationAndFiles)
{
//emit generated files...
}
Update:
Tested again with Visual Studio 17.4. and combination with compilation seems not to be necessary anymore. Generator is called as expected when appsettings.json changes with only AdditionalTextsProvider registered.
I have tried replicate but everything works for me.
I define my source generator as this
namespace ConsoleAppSourceGenerator
{
[Generator]
public class TxtGenerator : IIncrementalGenerator
{
private static int counter;
public void Initialize(IncrementalGeneratorInitializationContext initContext)
{
IncrementalValuesProvider<AdditionalText> textFiles = initContext.AdditionalTextsProvider
.Where(static file => file.Path.EndsWith(".txt"));
IncrementalValuesProvider<(string name, string content)> namesAndContents = textFiles
.Select((text, cancellationToken) => (name: Path.GetFileNameWithoutExtension(text.Path), content: text.GetText(cancellationToken)!.ToString()));
initContext.RegisterSourceOutput(namesAndContents, (spc, nameAndContent) =>
{
spc.AddSource($"TxtFile.{nameAndContent.name}.g.cs", $#"
// Counter {Interlocked.Increment(ref counter)}
public static partial class TxtFile
{{
public const string {nameAndContent.name} = ""{nameAndContent.content}"";
}}");
});
}
}
}
and source generator project as this
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>Latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.1.0" />
</ItemGroup>
</Project>
Then in another project, where I have made a dummy foo.txt file I have
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Remove="$(CompilerGeneratedFilesOutputPath)/**/*.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ConsoleAppSourceGenerator\ConsoleAppSourceGenerator.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
</ItemGroup>
<ItemGroup>
<AdditionalFiles Include="foo.txt"/>
</ItemGroup>
</Project>
If I through Visual Studio look at Dependencies->Analyzers->ConsoleAppSourceGenerator>TxtFile.foo.g.cs then it correctly increase the counter on every change I to in the file (see step 9).
I store generated files in path ConsoleApp/Generated/ConsoleAppSourceGenerator/ConsoleAppSourceGenerator.TxtGenerator and whenever I rebuild the project it correctly updates the files.
Have you remembered to add the [Generator] attribute to the IIncrementalGenerator?
Could you test this out and validates this doesn't either work for you?
"AdditionalFiles" in your consuming project file is the key to ensuring these files are captured by your source/incremental generator.
Found out that using a "<AdditionalFiles Include='...' />" is not necessary in some projects such as ASPNET Core projects for Source/IncrementalGenerators. The .cshtml files are included as additional files by default.
Also, file globbing patterns work with the "Include" parameter.
When I send an HTTP request to the function, It shows this error on console output, and returns HTTP 500 status code without hitting the the break point of function's first line.
Executed 'Validate' (Failed, Id=548b4612-42f8-4e49-886a-da6888045c32,
Duration=343ms) System.Net.Primitives: Value cannot be null.
(Parameter 'host') An unhandled host error has occurred.
System.Net.Primitives: Value cannot be null. (Parameter 'host').
Function
[FunctionName("Validate")]
public async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] string req,
[SignalR(HubName = "PubSub")] IAsyncCollector<SignalRMessage> signalRMessageQueue)
{
...
}
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
}
}
.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<RootNamespace>ZulaMobile.Lobby.StoreValidation</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.30" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.6.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.21" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\zulamobile-azure-lobby-common\zulamobile-azure-lobby-common.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Functions\CafeBazaar\" />
<Folder Include="Huawei\" />
</ItemGroup>
</Project>
I tried to reproduce the same issue but it worked fine at my end.
Followed by this MS DOC & demo GitHub project ,
Created a Signal IR in Azure portal .
Open the download folder from my VS Code-
And added the following packages into my local here is my .csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.6.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
</ItemGroup>
<ItemGroup>
<None Update="content\index.html">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
And make sure that you have added your connection string in your local settings.json which have to copy from portal from Azure signalIR > Keys>Connection string.
Here are some screenshot for reference output:
Note: If still facing the same issue you can try to Un install the Azure function V3 and install it again .
For more information please refer this SO THREAD .
I want to add OpenAPI specification to my Azure Functions app. For that I wanted to use AzureExtensions.Swashbuckle since it can auto generate the specification and display it via swagger-ui.
When I first install the package via nuget everything works fine. The specification is generated automatically, and I can view it through the swagger-ui.
As soon as I rebuild my project / solution, it doesn't build anymore. The following error message is prompted during the build:
3>C:\Users\Agent1\.nuget\packages\microsoft.net.sdk.functions\3.0.13\build\Microsoft.NET.Sdk.Functions.Build.targets(32,5): Error : Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Microsoft.AspNetCore.Mvc.Core, Version=3.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name)
at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
at Mono.Cecil.ModuleDefinition.Resolve(TypeReference type)
at Mono.Cecil.TypeReference.Resolve()
at MakeFunctionJson.AttributeExtensions.IsWebJobsAttribute(CustomAttribute attribute)
at MakeFunctionJson.ParameterInfoExtensions.<>c.<ToFunctionJsonBindings>b__1_0(CustomAttribute a)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.ToList()
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at MakeFunctionJson.ParameterInfoExtensions.ToFunctionJsonBindings(ParameterDefinition parameterInfo)
at MakeFunctionJson.MethodInfoExtensions.<>c.<ToFunctionJson>b__6_1(ParameterDefinition p)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at MakeFunctionJson.MethodInfoExtensions.ToFunctionJson(MethodDefinition method, String assemblyPath)
at MakeFunctionJson.FunctionJsonConverter.GenerateFunctions(IEnumerable`1 types)+MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at MakeFunctionJson.FunctionJsonConverter.TryGenerateFunctionJsons()
at MakeFunctionJson.FunctionJsonConverter.TryRun()
Error generating functions metadata
I'm using AzureFunctions V3 with .NET Core 3.1.
This is my .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
<OutputPath>../../dist/apps/api</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AzureExtensions.Swashbuckle" Version="3.3.2" />
<PackageReference Include="CSharpFunctionalExtensions" Version="2.18.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="5.0.0-beta.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.17">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.17" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.12.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
<PackageReference Include="Scriban" Version="4.0.1" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.8.1" />
<PackageReference Include="System.ServiceModel.Http" Version="4.8.1" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.8.1" />
<PackageReference Include="System.ServiceModel.Security" Version="4.8.1" />
</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 already deleted my local .nuget directory, cleaned nuget cache and updated other packages but no luck.
If you added [FromQuery] or any other attribute to your azure function "controller signature" it could happened.
You can try to remove the [FromQuery] attribute.
You can refer this on-going github issue about the same problem.
I have downloaded one of my old projects and when I tried to run the Update-Database from the Package Manager Console I get the following message
Build started... Build succeeded. An error occurred while accessing
the Microsoft.Extensions.Hosting services. Continuing without the
application service provider. Error: Value cannot be null. (Parameter
's') No DbContext was found in assembly 'BusinessLogicLayer'. Ensure
that you're using the correct assembly and that the type is neither
abstract nor generic.
The difference between now and when I have used the application last time is that I have reset windows, and reinstalled all the programs back.
The application runs normally and I managed to add the migrations using
CreateHostBuilder(args)
.Build()
.MigrateDatabase<DataContext>()
.Run();
and all tables have been created and populated with the seed data.
The last time I have been working on this project everything was working just fine.
This is how I connect to the DB
services.AddDbContext<DataContext>(optionsBuilder =>
optionsBuilder.UseNpgsql("User ID=postgres;Password=my_actual_pass;Server=localhost;Port=5432;Database=medication_platform3;Integrated Security=true;Pooling=true;"));
Constructor for DataContext
public DataContext(DbContextOptions<DataContext> options)
: base(options) { }
DataAccessLayer
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Migrations\**" />
<EmbeddedResource Remove="Migrations\**" />
<None Remove="Migrations\**" />
</ItemGroup>
<ItemGroup>
<Compile Include="Migrations\20201207230245_InitialMigration.cs" />
<Compile Include="Migrations\20201207230245_InitialMigration.Designer.cs" />
<Compile Include="Migrations\DataContextModelSnapshot.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="5.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="6.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BusinessObjectLayer\BusinessObjectLayer.csproj" />
</ItemGroup>
</Project>
appsettings.json
{
"JwtKey": "SOME_RANDOM_KEY_DO_NOT_SHARE",
"JwtIssuer": "http://localhost:5001",
"JwtExpireDays": 1,
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
I can provide more information if needed.
After using update-database -verbose
I was able to track the line with the problem.
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
int port = int.Parse(Environment.GetEnvironmentVariable("PORT"));
....
}
This was a configuration made for the deployment and I forgot to change this line to
int port= 5001
deploying from VS version on the app service is: 2.1.403
and version on my local is: 2.1.403
here is a copy of the relevent section of the .csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
<UserSecretsId>952fa24f-1cbc-4017-8cdc-4b99e3671be7</UserSecretsId>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
<RuntimeIdentifiers>win10-x64;</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<Compile Remove="NewFolder\**" />
<Content Remove="NewFolder\**" />
<EmbeddedResource Remove="NewFolder\**" />
<None Remove="NewFolder\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Bogus" Version="24.3.0" />
<PackageReference Include="MediatR" Version="5.1.0" />
<PackageReference Include="MediatR.Extensions.Microsoft.DependencyInjection" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.4" />
<PackageReference Include="Microsoft.AspNetCore.All"/>
<PackageReference Include="Microsoft.AspNetCore.App"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.5" />
</ItemGroup>
I've tried:
using a self-contained deployment
specifying the version of the packages to 2.1.5 (though i've read this is not necessary)
my runtime.config in the build artifacts looks good:
{
"runtimeOptions": {
"tfm": "netcoreapp2.1",
"framework": {
"name": "Microsoft.AspNetCore.All",
"version": "2.1.5"
},
"configProperties": {
"System.GC.Server": true
}
}
}
so what am I missing here?
This fixed the issue:
<PackageReference Include="Microsoft.AspNetCore.All Version="2.1.1"/>
Though it could be a red herring as I have no idea why specifying the app version would fix (I thought the point of the shared framework was to dynamically pull in the versions you need.)
Also if it helps anyone: 2.1.5 is the release number and NOT THE VERSION OF THE SDK (it corresponds to 2.1.403)