简体   繁体   中英

dotnet compiler error while publishing f# 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM