Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need to add "Compile Include ..." to use files generated during the build but this causes more errors #1822

Closed
asfernandes opened this issue Oct 30, 2017 · 9 comments · Fixed by OmniSharp/omnisharp-roslyn#1002
Assignees
Milestone

Comments

@asfernandes
Copy link

Environment data

dotnet --info output:

Ferramentas de Linha de Comando do .NET (2.0.0)

Product Information:
 Version:            2.0.0
 Commit SHA-1 hash:  cdcd1928c9

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\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d

VS Code version: 1.17.0
C# Extension version: 1.12.0 (I think)

Steps to reproduce

The attached project uses <Compile Include="$(IntermediateOutputPath)\*.cs" /> so GrammarParser is recognized. But usage of Compile causes others problems in Problems view and with dotnet cli.

If I remove Compile the project builds correctly with dotnet cli, but then OmniSharp does not recognize GrammarParser.

@asfernandes
Copy link
Author

antlr4-netcore2.zip

@DustinCampbell
Copy link
Member

Many thanks for the detailed repro! I can definitely reproduce with this project.

@DustinCampbell
Copy link
Member

Thanks again for the repro project. I have found the cause of the issue. We are failing to set the BuildingInsideVisualStudio in OmniSharp, which causes the Antlr targets to fail to include the generated files.

You can workaround this problem by setting BuildingInsideVisualStudio as an environment variable. Here's what I did from a Visual Studio Command Prompt.

> set BuildingInsideVisualStudio=true
> code .

No errors!

@DustinCampbell
Copy link
Member

OK. I have a fixed checked into OmniSharp to address this issue. It turned out to not be the same root cause as #1531, so I appreciate you taking the time to file this with an excellent repro.

Once we take a new release of OmniSharp into C# for VS Code, I'll close this issue.

@asfernandes
Copy link
Author

> set BuildingInsideVisualStudio=true
> code .

I confirm this works when the files are already in obj, created by dotnet build.

But if I clean obj, should OmniSharp also cause the files to be generated? Currently it is not.

@DustinCampbell
Copy link
Member

It won't generate the files simply by passing that variable, but it will with my full OmniSharp change. The project needs to be restored first though. There is an issue in OmniSharp where it won't reload a project after a restore in some cases (and this is one of them). However, if the project is already restored, the files will be generated when OmniSharp loads the project. I just tried this to verify.

@DustinCampbell DustinCampbell added this to the 1.13 milestone Nov 6, 2017
@DustinCampbell
Copy link
Member

@asfernandes : I just wanted to let you know that I just released on a new beta of C# for VS Code that fixes this issue: 1.3.0-beta5. You can following these instructions if you're interested in trying it out.

@asfernandes
Copy link
Author

Seems working. It does not update generated files automatically when I save .g4 files, but it updates when I run the build target in vscode.

@DustinCampbell
Copy link
Member

Correct. It will only regenerate the files when MSBuild runs. That happens on initial project loading and during build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants