I have a .NET Standard 2.0 project which is using Serilog assembly to log using serilog, here is project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyTitle>Logger</AssemblyTitle>
<Description>Client Web Logger</Description>
<AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Win32.Registry" />
<PackageReference Include="SchneiderElectric.Software.SASigning" />
<PackageReference Include="Serilog" />
<PackageReference Include="Serilog.AspNetCore" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" />
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="SET _WWBinDir="$(ProjectDir)..\..\..\interfaces\bin\$(ConfigurationName)\$(PlatformName)"
MKDIR %_WWBinDir%
robocopy "$(TargetDir) " "%_WWBinDir%" InSightLogger.dll /ZB /NJH /NJS /NDL /NFL /NC /NS
:END
exit 0
" />
</Target>
I have two other projects in my solution one is in .NET 6.0 and other one is in NET Framework 4.8
here is project files of .NET 6.0:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup Label="Globals">
<Description>My Server</Description>
<TypeScriptToolsVersion>3.1</TypeScriptToolsVersion>
<TargetFramework>net6.0</TargetFramework>
<_HasReferenceToSystemRuntime>true</_HasReferenceToSystemRuntime>
<RootNamespace>My.Insight</RootNamespace>
<DefineConstants>DESKTOP;LICENSEREQUIRED</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Remove="App_Start\**" />
<Content Remove="App_Start\**" />
<EmbeddedResource Remove="App_Start\**" />
<None Remove="App_Start\**" />
</ItemGroup>
<ItemGroup>
<Folder Include="..\..\Common\wwwroot\Insight" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Favorites\FavoriteApiModel\FavoriteApiModel.csproj" />
<ProjectReference Include="..\..\Logger\Logger\Logger.csproj" />
<ProjectReference Include="..\LicenseUtil\LicenseUtil.csproj" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.2.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="WWMenuHttpModule" Version="4.0.21100101" />
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" />
</ItemGroup>
And Framework project file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<RootNamespace>my.InSight</RootNamespace>
<TargetFramework>net48</TargetFramework>
<AssemblyTitle>Article Server Service</AssemblyTitle>
<NeutralLanguage>en-US</NeutralLanguage>
<Description>Article Service</Description>
</PropertyGroup>
<Import Project="..\..\..\SharedComponents\External\StyleCop\StyleCop.Targets" />
<ItemGroup>
<PackageReference Include="System.Net.Http" />
<PackageReference Include="Newtonsoft.Json" />
<PackageReference Include="StyleCop" />
<PackageReference Include="System.Configuration.ConfigurationManager" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Logger\Logger\Logger.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Management" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Configuration.Install" />
</ItemGroup>
<ItemGroup>
<Compile Update="ProjectInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="ProjectInstaller.Designer.cs">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</Compile>
<Compile Update="myService.cs">
<SubType>Component</SubType>
</Compile>
<Compile Update="myService.Designer.cs">
<DependentUpon>myService.cs</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="ProjectInstaller.resx">
<DependentUpon>ProjectInstaller.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Update="myService.resx">
<DependentUpon>myService.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.CodeAnalysis.FxCopAnalyzers" />
</ItemGroup>
for .NET 6.0 all thing is working fine but for .NET Framework 4.8 it through exception when I am accessing logger projects static class and method, here is exception I am getting
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files (x86)\WonderWorld\MyInsight\Server\aahInSightHost.exe
--- A detailed error log follows. --Pre-bind state information --
LOG: DisplayName = netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/WonderWorld/MyInsight/Server/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = aahInSightHost.exe
Calling assembly : Serilog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=24c2f752a8e58a10.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Program Files (x86)\WonderWorld\MyInsight\Server\aahInSightHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Wonderware/HistorianInsight/Server/netstandard.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Wonderware/HistorianInsight/Server/netstandard/netstandard.DLL.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Wonderware/HistorianInsight/Server/netstandard.EXE.
LOG: Attempting download of new URL file:///C:/Program Files (x86)/Wonderware/HistorianInsight/Server/netstandard/netstandard.EXE.
LOG: All probing URLs attempted and failed.
Note: only one thing I noted that I created netstandard2.0 project and in logs it is mentioned that netstandard 2.1.0.0 is searching for, but could not understand.
By closely investigating your project files I came to know that you are using dotnet standard 2.0 but in error it searches from dotnet standard 2.1 so you need to verify all projects with used package version and use appropriate one.
Related
I have an Azure Function which run on .net core 3.1, but when i change the .net version from 3.1 to 7 i got this error:-
System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.'
here is a screen shot:-
here is my csproj file:-
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.15.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
<PackageReference Include="PnP.Core.Auth" Version="1.8.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>
Any advice on this please?
I have installed Install-Package Microsoft.Extensions.Configuration.Abstractions -Version 7.0.0 but this did not fix the issue either.
.NET 3.1 is in-process and .NET 7 is Isolated Worker Process type.
I can see your .csproj file code given in the question that you changed only .NET Framework and Azure Functions Version which is not complete configuration code for .NET 7 Isolated Process Azure Function and also you're missing few Function Worker package references in the .csproj file code.
Basic/Default .NET 7 Isolated Azure Functions Project contains the below code in .csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.8.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.2.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.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>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
.NET 7 In-Process is not yet released and to convert from .NET 3.1 (In-Process Model) to .NET 7 (Isolated Worker Process), you need to write the .NET 7 Isolated Compatible NuGet Packages, code changes in the Function Code, program.cs file, etc.,
Refer to this MS Doc for Migration Steps & Checks of Azure Functions V3 to V4 and One of the my answers SO #74428448 states the update of the supported available version in Azure Functions C#.
Have defined multitarget project:
<Project Sdk="MSBuild.Sdk.Extras/2.0.54">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;xamarinios10;monoandroid9.0;</TargetFrameworks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<EnableDefaultEmbeddedResourceItems>false</EnableDefaultEmbeddedResourceItems>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.6.0.800" />
<PackageReference Include="Xamarin.Essentials" Version="1.5.3" />
<Compile Include="**\Shared\*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('xamarinios')) ">
<Compile Include="**\iOS\*.cs" />
</ItemGroup>
<ItemGroup Condition=" $(TargetFramework.StartsWith('monoandroid')) ">
<Compile Include="**\Android\*.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Shared\MyView.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>
So, when i make my custom component only in code all compile and works well, but i would like to develop some custom controls using XAML.
But i got error of ambiguous call to method InitializeComponent() in MyView object.
How to make correct conditional configuration in .csproj for compiler to understand *.xaml and *.xaml.cs files ?
Adding these properties to common ItemGroup solved the problem:
<None Remove="**\Shared\*.xaml" />
<Compile Include="**\Shared\*.xaml.cs" DependentUpon="%(Filename)" />
<EmbeddedResource Include="**\Shared\*.xaml" Generator="MSBuild:UpdateDesignTimeXaml" />
I'm working on creating sample for clean architecture. When I had made core and infrastructure projects there were no problems. No I had add new API project and I got problem, picture bellow
I had tried to add project references in csproj but still have a problem, can anyone help me to fix this problem ?
Here is the link for project: https://github.com/danijel88/Clean-Architecture
Regards,
Danijel
Here's a question similar to yours
Here's a sample .csproj. Be sure to have
<TargetFramework>netcoreapp2.2</TargetFramework>
Make sure your project is on 2.2 before updating your packages to 2.2.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TypeScriptToolsVersion>3.1</TypeScriptToolsVersion>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<CopyRefAssembliesToPublishDirectory>false</CopyRefAssembliesToPublishDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Gelf.Extensions.Logging" Version="1.5.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" />
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.1" />
<PackageReference Include="SlackLogger" Version="2.0.5" />
<PackageReference Include="System.Xml.Linq" Version="3.5.21022.801" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Nozomi.Infra.Preprocessing\Nozomi.Infra.Preprocessing.csproj" />
<ProjectReference Include="..\Nozomi.Infra.Service.Identity\Nozomi.Infra.Service.Identity.csproj" />
<ProjectReference Include="..\Nozomi.Infra.Service\Nozomi.Infra.Service.csproj" />
</ItemGroup>
<ItemGroup>
<_ContentIncludedByDefault Remove="Areas\Identity\Pages\_ViewImports.cshtml" />
</ItemGroup>
</Project>
I am trying to publish a dotnet core 2.0.0 (release version) project from command line.
I am getting an error as below.
EXEC(1,1): error CS8301: Invalid name for a preprocessing symbol; '' is not a valid identifier [C:\Work\FloAppGit\FloAppStpl\FloMa
nufacturer\FloManufacturer.fsproj]
C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.0\build\netstandard2.0\Microsof
t.AspNetCore.Mvc.Razor.ViewCompilation.targets(60,5): error MSB3073: The command ""C:\Program Files\dotnet\dotnet.exe" exec --runt
imeconfig "C:\Work\FloAppGit\FloAppStpl\FloManufacturer\bin\Debug\netcoreapp2.0\FloManufacturer.runtimeconfig.json" --depsfile "C:
\Work\FloAppGit\FloAppStpl\FloManufacturer\bin\Debug\netcoreapp2.0\FloManufacturer.deps.json" "C:\Program Files\dotnet\sdk\NuGetFa
llbackFolder\microsoft.aspnetcore.mvc.razor.viewcompilation\2.0.0\build\netstandard2.0\Microsoft.AspNetCore.Mvc.Razor.ViewCompilat
ion.dll" #"obj\Debug\netcoreapp2.0\microsoft.aspnetcore.mvc.razor.viewcompilation.rsp"" exited with code 1. [C:\Work\FloAppGit\Flo
AppStpl\FloManufacturer\FloManufacturer.fsproj]
My project file is as follows.
<Project Sdk="FSharp.NET.Sdk;Microsoft.NET.Sdk.Web">
<PropertyGroup>
<EnableDefaultCompileItems>False</EnableDefaultCompileItems>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeFrameworkVersion>2.0.0</RuntimeFrameworkVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="Controllers/*.fs" />
<Compile Include="FloLogger.fs" />
<Compile Include="Restful.fs"/>
<Compile Include="AppSettingsHelper.fs" />
<Compile Include="DataRecords/BusinessRecords.fs"/>
<Compile Include="DAL/ManufacturerDAL.fs"/>
<Compile Include="DAL/ItemManufacturerDAL.fs"/>
<Compile Include="BAL/ItemManufacturerBAL.fs"/>
<Compile Include="BAL/ManufacturerBAL.fs"/>
<Compile Include="Manufacturer.fs" />
<Compile Include="ItemManufacturer.fs" />
<Compile Include="Startup.fs" />
<Compile Include="Program.fs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
<PackageReference Include="log4net" Version="2.0.8" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="RavenDB.Client" Version="4.0.0-beta-40016" />
<PackageReference Include="Polly" Version="5.1.0" />
<PackageReference Include="Suave" Version="2.0.3.0" />
<PackageReference Include="Suave.AspNetCore" Version="0.3.0" />
<PackageReference Include="Suave.DotLiquid" Version="2.0.3" />
<PackageReference Include="xunit" Version="2.2.0" />
</ItemGroup>
Please help me resolve this issue as I am stuck.
I was able to resolve the issue by commenting these lines in the project file.
<PackageReference Include="FSharp.Core" Version="4.1.*" />
<PackageReference Include="FSharp.NET.Sdk" Version="1.0.*" PrivateAssets="All" />
Also I had to change the header of the project file like this.
<Project Sdk="Microsoft.NET.Sdk.Web">
Delete the obj and bin folders. Do a dotnet clean then dotnet restore.
I was able to publish the code successfully for dotnet core 2.0.0 release version.
Using Visual Studio 2017 Community. My .NetCoreApp 1.1 project has included 2 packages from nuget that are yielding the little yellow warning label. The packages are obviously not loading correctly and I would like to know why.
I have looked in output
I have looked in package manager console
I have built and rebuilt the project
The packages in question are :
Microsoft.AspNetCore.WebSockets (1.0.1)
Microsoft.AspNetCore.WebSockets.Protocol (0.1.0)
Additionally, this is not an issue with my other .NetCore 1.1 project in the same solution.
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets" Version="1.0.1" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets.Protocol" Version="0.1.0" />
<PackageReference Include="Microsoft.AspNetCore.WebSockets.Server" Version="0.1.0" />
</ItemGroup>
</Project>