dotnet compiler error while publishing f# project - asp.net

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.

Related

Issue with .NET Standard 2.0 project with Serilog assembly

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.

Xamarin.Forms SDK-Style multiplatform project with XAML

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" />

VS2019 Error Says Project is Targetting 'netcoreapp3.1' when it is Targetting netcoreapp2.2

I have a multi-project solution that was working fine in VS2017, I've installed VS2019 and on compile I receive five error messages:
Four of the format: This version of Microsoft.AspNetCore.App is only compatible with netcoreapp2.2 taret framework. Please target netcoreapp2.2 or chose a version of Microsoft.AspNetCore.app compatible with netcoreapp3.1
And one of the format: Project '..\project-path\project.csproj' targets 'netcoreapp3.1;. It cannot be reference by a project that targets '.NETCoreApp,Version=v2.2'
Additionally if you look at the projects referenced in the error messages the Dependencies, Packages, SDK all have the yellow warning symbol on them (hover and right-click don't seem to provide additional details)
I've tried cleans, delete bin and obj folders, rebuilds, checking SDK versions, but no luck
I can confirm I have a global.json with the SDK version (2.2.103) and that when in any of these projects directories and I run 'dotnet --verson' I get back 2.2.103
What is happening here? What / where is it picking up netcoreapp3.1 from and how do I resolve these errors?
Update: CSPROJ Details
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<None Include="appsettings.json" CopyToOutputDirectory="Always" />
<None Include="favicon.ico" CopyToOutputDirectory="Always" />
<None Include="appDevLocalOverride.json" />
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="3.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.8.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.AzureKeyVault.HostingStartup" Version="2.0.2" />
<PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="3.1.2" />
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.3" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="2.2.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration.AzureKeyVault" Version="2.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
</ItemGroup>
I'm not sure why or how this works, but I have stumbled on a solution:
Open the csproj
Edit <PackageReference Include="Microsoft.AspNetCore.App" /> to <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" />
Build > Clean Solution
Manually remove ALL bin and obj folders (even if they are only remotely related to the solution)
Build > Rebuild Solution
Edit <PackageReference Include="Microsoft.AspNetCore.App" Version="2.2.0" /> to <PackageReference Include="Microsoft.AspNetCore.App" />
That seemed to work for me, why a simple Clean Solution and Rebuild wasn't the answer is odd; but hopefully this will help someone else!

Nuget Packages Conflict .net core

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>

How to print visual studio 2017 nuget project reference warnings

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>

Resources