My solution uses the latest version of .net which is 4.8. However, I see the following error message that complaints about a version 4.0 in Azure Pipelines. Can someone let me know how I could resolve this please ?
The error message indicates I need to install 4.0 but I don't think that's the solution. I also opened up the file Microsoft.Common.CurrentVersion.targets and line 1221 has the following. However, I know it is not advisable to edit this file.
<!-- By default if there is no root path set then the task will assume it is Program Files\Reference Assemblies\Microsoft\Framework-->
<GetReferenceAssemblyPaths
Condition="'$(TargetFrameworkMoniker)' != '' and ('$(_TargetFrameworkDirectories)' == '' or '$(_FullFrameworkReferenceAssemblyPaths)' == '')"
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
RootPath="$(TargetFrameworkRootPath)"
TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)"
BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)"
>
<Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
<Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName" Condition="'$(TargetFrameworkMonikerDisplayName)' == ''"/>
</GetReferenceAssemblyPaths>
The error message:
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1221,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
Note: There are many similar post in SO that suggest to install VS2019. However, I am getting this message while running the application on Azure Pipelines.
Update
From your description, you are using the Microsoft host agent and the pipeline pop out issue 'cannot found NETFramework,Version=v4.0'.
Your environment looks like this:
https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md#net-framework
or
https://github.com/actions/virtual-environments/blob/main/images/win/Windows2022-Readme.md#net-framework
You can see that the Microsoft host agent does not have the environment you mentioned.
Although you can install what you need at the beginning of the pipeline startup, I do not recommend this practice. Because when you choose microsoft host agent, every time you start the pipeline, you will be assigned a brand new azure VM machine, which means you need to install the relevant environment every time.
The recommended approach is to use a self-host agent. Please create a self-host agent based on your local machine (or another machine with the relevant environment), the steps are as follows:
https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-windows?view=azure-devops
Provided above are the installation steps of windows self host agent, the steps should be very simple, if you encounter any problems please let me know.
And after that, you can run your pipeline based on that self host agent like this:
pool:
name: <your agent pool name>
If you are using classic pipeline, just click and select:
(If you run successfully on local, then the agent based on local machine should also be no problem.)
And if this is still unable to solve your issue, could you please remove the in-private information and share the YAML file or JSON file, and let me know at which step you encountered this issue?
I have used Visual Studio 2017 (on Windows) to create my .Net Core App and am trying to run it inside a docker container. Based on their website .NET Core Apps should allow us developers to create cross-platform compatible software;
.NET Core is a cross-platform version of .NET for building websites,
services, and console apps.
My attempt on that was to create a .NET Core Console Application;
using System;
using Newtonsoft.Json;
namespace Services
{
class Program
{
static void Main(string[] args)
{
if (Enum.TryParse(
typeof(LoremIpsumGenerator.TypeOfGenerator),
args[0],
true,
out var testParse))
{
Console.WriteLine(
JsonConvert.SerializeObject(
LoremIpsumGenerator
.GenerateText(
int.Parse(args[1]),
(LoremIpsumGenerator.TypeOfGenerator) testParse)));
}
Console.WriteLine("Wrong Parameters!");
}
}
}
Publish it via dotnet publish and run it by the following;
FROM microsoft/aspnetcore:1.0.13-nanoserver-sac2016 AS base
WORKDIR /Services
COPY /bin/Debug/netcoreapp2.0/publish/ .
ENTRYPOINT ["dotnet", "DockerConsoleTestApp.dll"]
.. however I do always seem to get the following error-message;
image operating system "windows" cannot be used on this platform
.. which I interpret as "You should use Windows-container to run this". But now I am confused since both my console application and my container should both be cross-platform compatible, right? Or am I missing something?
The line:
FROM microsoft/aspnetcore:1.0.13-nanoserver-sac2016 AS base
is loading a microsoft nanoserver 2016 as base image. THis is a windows server, not a linus server. OBVIOUSLY the resulting image must run on a WIndows Kernel.
Use a Linux base image if you want a Linux base image.
There are two relevant links:
As you said, you used an official repository. Well, it has a website at https://hub.docker.com/r/microsoft/aspnetcore/ that lists all images, windows AND linux.
There is documentation at https://learn.microsoft.com/en-us/dotnet/core/docker/building-net-docker-images about how to build a base image that goes to this topic (look for Linux) in detail, too.
There simply is no way to make the platform apltform independent. As docker does not run a VM but "slim" virtualization sharing the main OS.... the main OS of the image MUST match.
I'm deploying a asp.net core 2.0 website to IIS 10.
I've made sure that my app is using the correct configuration for ISS in the program.settings file.
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
}
And in my startup.cs file:
public void ConfigureServices(IServiceCollection services)
{
services.Configure<IISOptions>(options =>
{
});
services.AddMvc();
}
Yet when I run dotnet website.dll from the command line I get the below error message shown in the command line window:
An assembly specified in the application dependencies manifest
(website.deps.json) was not found:
package: 'Microsoft.AspNetCore.Antiforgery', version: '2.0.1'
path: 'lib/netstandard2.0/Microsoft.AspNetCore.Antiforgery.dll' This assembly was expected to be in the local runtime store as the
application was published using the following target manifest files:
aspnetcore-store-2.0.3.xml
Based off the error message, i'm guessing Microsoft.AspNetCore.Antiforgery isn't being bundled when I publish since I do not receive this error when debugging.
How can I ensure that my app can find Microsoft.AspNetCore.Antiforgery when published to a live environment?
EDIT: This is a basic .net core website. No changes have been made to the standard project at this time apart from the above changes for deployment with IIS.
When I run the project from IIS instead of the command line I get a 502.5 error message.
I was able to fix this issue by updating the .net core runtime on the server to v2.0.3.
This issue occurs if
You have an existing server running v2.0.0 of the .net core runtime.
You create an app targeting v2.0.3 of the SDK
You publish the v2.0.3 app to a server running v2.0.0
The issue can be resolved by installing v2.0.3 of the runtime on the server. You can download the runtime from the microsoft site here https://www.microsoft.com/net/download/windows
If you are actually using this library, make sure that your *.csproj file has the corresponding explicit reference:
<PackageReference Include="Microsoft.AspNetCore.Antiforgery" Version="..." />
Then, play with the PublishWithAspNetCoreTargetManifest property to resolve the aforementioned issue with a mismatched manifest.
Check out the following threads to learn more about possible issues while its deployment:
An assembly specified in the application dependencies manifest (RhWeb.deps.json) was not found
published application is missing assembly (missing runtime store associated ...) [2.0.0-preview2-005905]
HTTP Error 502.5 - Microsoft.AspNetCore.Antiforgery.dll
I had this issue - simple workaround, actually install the NuGet package (I wasn't using it).
Microsoft.AspNetCore.Antiforgery
Published, deployed - fixed the issue.
In another case, when I published the project, a lot of the dlls weren't being placed in the publish folder - including Antiforgery. The below appears to force publishing to add all the required dlls.
Edit your projectname.json file to ensure PropertyGroup contains PublishWithAspNetCoreTargetManifest = false:
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
</PropertyGroup>
Interested to know why the above works?!
This also problem happens if Antiforgery is called but Antiforgery is not installed.
Can be fixed by installing Microsoft.AspNetCore.Antiforgery by Nuget package manager.
I fixed this issue on my inhouse windowsserver with this solution
* go to netcore https://github.com/dotnet/core/tree/master/release-notes
* go to the lastest version of the core runtime 2.?
* download DotNetCore.2.0.6-WindowsHosting.exe in my case
https://github.com/dotnet/core/blob/master/release-notes/download-archives/2.0.6-download.md#net-core-runtime-only-installation
Install this on server and the error was solved for me. Hope this helps anyone.
Got this error after updating Microsoft.AspNetCore.All from v2.0.7 to v2.0.8 (latest at the time) and then publishing to a server that was running .NET Core Runtime v2.0.7 (latest at the time).
Downgraded Microsoft.AspNetCore.All back down to v2.0.7, re-published, and everything works.
If you publish the app as a self-contained ASP.NET Core 2.2 apps as per the linked screenshot (I don't have enough rep for inline image), it will fix this issue.
Self contained:
This can be set when editing your publish settings.
If this issue is related to your Razor mail template, you can add "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation". When I add, the problem is solved.
I have written a service in C#. I kept the DLLs of my service in c:\windows\system32\myservice.dll. I have done the necessary registry changes for hosting in svchost.exe, but my service is not being executed. It gets a 1053 error code.
The following is the registry entry for myservice. I created a key and have given the path of the myservice.dll file.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\svcsvc2]
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,00,\
74,00,25,00,5c,00,73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,\
00,76,00,63,00,68,00,6f,00,73,00,74,00,2e,00,65,00,78,00,65,00,20,00,2d,00,\
6b,00,20,00,4c,00,6f,00,63,00,61,00,6c,00,53,00,65,00,72,00,76,00,69,00,63,\
00,65,00,00,00
"DisplayName"="#%SystemRoot%\\system32\\svcsvc.dll,-200"
"ObjectName"="NT AUTHORITY\\LocalService"
"ServiceSidType"=dword:00000001
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\svcsvc2\Parameter]
"ServiceDll"=hex(2):25,00,53,00,79,00,73,00,74,00,65,00,6d,00,52,00,6f,00,6f,\
00,74,00,25,00,5c,00,53,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,\
73,00,76,00,63,00,73,00,76,00,63,00,2e,00,64,00,6c,00,6c,00,00,00
"ServiceMain"="Main"
1053 is ERROR_SERVICE_REQUEST_TIMEOUT
The service did not respond to the start or control request in a
timely fashion.
StartServiceCtrlDispatcher was not called?
You also have type set to SERVICE_WIN32_OWN_PROCESS, not SERVICE_WIN32_SHARE_PROCESS.
And please respect this note from MSDN:
Note that Svchost.exe is reserved for use by the operating system and
should not be used by non-Windows services. Instead, developers should
implement their own service hosting programs.
svchost doesn't host the .NET framework, so is not able to execute your .NET assembly.
.NET services run with their own applications (.exe).
Why not creating a Setup Project in VS that installs your service?
Unless you want to install a service programatically, I would advise you to read this article.