question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

F# project deps file has entry entry in defines causing a compilation failure

See original GitHub issue

Apologies if this is not the right home, I’m trying to find the correct routing for this issue.

Using an FSharp project, the `.deps.json file contains:

{
  "runtimeTarget": {
   ...
  },
  "compilationOptions": {
    "defines": [
      "",
      "TRACE",
      "DEBUG",
      "NETCOREAPP2_0"
    ],
    ...
  },

When we read the deps file and hand this off to Roslyn, the result is a compilation error:

Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: One or more compilation failures occurred:
fdw11r2q.auy(1,1): error CS8301: Invalid name for a preprocessing symbol; '' is not a valid identifier
   at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(RazorCodeDocument codeDocument, String generatedCode)
   at Microsoft.AspNetCore.Mvc.Razor.Internal.RazorViewCompiler.CompileAndEmit(String relativePath)

Removing the ‘empty define’ by editing the deps file makes compilation succeed.


We set up the compilation options by using the DependencyContext to read the deps file: https://github.com/aspnet/Mvc/blob/dev/src/Microsoft.AspNetCore.Mvc.Razor/Internal/DependencyContextRazorViewEngineOptionsSetup.cs

This was working until recently, and we have working setups that do contain the ‘empty define’.

But it still doesn’t seem right to have an empty define since that is illegal. I think the F# SDK is doing something wrong.


Dependency model version: 2.0.0-preview2-25407-01

dotnet --info

.NET Command Line Tools (2.0.0-preview2-006492)

Product Information:
Version:            2.0.0-preview2-006492
Commit SHA-1 hash:  7ab3d5b8d8

Runtime Environment:
OS Name:     Windows
OS Version:  10.0.15063
OS Platform: Windows
RID:         win10-x64
Base Path:   C:\Program Files\dotnet\sdk\2.0.0-preview2-006492\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0-preview2-25407-01
  Build    : 40c565230930ead58a50719c0ec799df77bddee9

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
eerhardtcommented, Jun 23, 2017

We could also add a safe-guard for this type of error in the future by using StringSplitOptions.RemoveEmptyEntries here:

https://github.com/dotnet/sdk/blob/master/src/Tasks/Microsoft.NET.Build.Tasks/CompilationOptionsConverter.cs#L20

0reactions
eerhardtcommented, Oct 4, 2017

Looks like ‘no’. I added https://github.com/dotnet/sdk/issues/1628

Read more comments on GitHub >

github_iconTop Results From Across the Web

maven compilation failure
Compiling all the modules (or modules in the proper hierarchical dependency order) resolves this error, if this is the nature of your problem....
Read more >
Linker Tools Error LNK2019
If a symbol is referred to but never defined, the linker generates an unresolved external symbol error. Here are some common problems that...
Read more >
GN Reference
"error": This will only be present if an error occurred, and will contain a string describing the error. This includes cases where the...
Read more >
Quarkus and Maven
The project is generated in a directory named after the passed artifactId. ... are detected the Java files are compiled, and the application...
Read more >
Deps and CLI Reference
The Clojure CLI will configure the JVM process by defining a classpath (with desired libraries), an execution environment (JVM options), the main class,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found