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

Azure Pipelines Build/VisualStudio DesignTime magic #338

Open
cpyfferoen opened this issue Sep 16, 2019 · 4 comments
Open

Azure Pipelines Build/VisualStudio DesignTime magic #338

cpyfferoen opened this issue Sep 16, 2019 · 4 comments

Comments

@cpyfferoen
Copy link

There are a host of issues logged that discuss dotnet core etc. specifically #208 but...

  • I cannot for the life of me determine how to get Antlr/build to work on Azure Pipelines.
  • Everything works fine w/ VS2019 on my local machine
    • "fine" meaning, from a clean state I have to build twice.. we'll call that a non-issue for now I guess
  • Or if there was a way to call MSBuild from Powershell and get it to generate the Antlr code??
    • but I can't figure that out either.. if that worked i could at least do that in a Devops Pipeline

Please help guide me?
csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netcoreapp3.0;netstandard2.1</TargetFrameworks>
    <NeutralLanguage>en-US</NeutralLanguage>
    <LangVersion>7.3</LangVersion>
    <Version>1.1.0-dev</Version>
    <Antlr4UseCSharpGenerator>true</Antlr4UseCSharpGenerator>
    <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
    <AutoGenerateBindingRedirects>false</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Antlr4" Version="4.6.6" />
    <PackageReference Include="StringTemplate4" Version="4.0.9-rc1" />
  </ItemGroup>
  <ItemGroup>
    <Antlr4 Update="NeutralTextParser\NTLexer.g4">
      <CustomToolNamespace>MagicNamespace</CustomToolNamespace>
      <Listener>False</Listener>
      <Visitor>False</Visitor>
    </Antlr4>
  </ItemGroup>
</Project>

azure yaml

- task: MSBuild@1
  continueOnError: true
  displayName: 'Try MSBuild'
  inputs:
    solution: '$(project)'
    platform: $(buildPlatform)
    configuration: $(buildConfiguration)

- task: DotNetCoreCLI@2
  displayName: 'Just for fun, see if msbuild made the files..'
  inputs:
    command: 'build'
    projects: $(project)
@cpyfferoen
Copy link
Author

cpyfferoen commented Sep 17, 2019

Update - perhaps it has something to do with a fragments file -
I do have an import MagicFragments; line in two Lexers, but I did not have a build task for the fragments - trying this now..
Yeah.. I can't get any dotnet build or dotnet msbuild working w/ an import MagicFragments in it. It magically works as soon as I open VisualStudio, it creates the *.tokens files.. but seems like black magic since it doesn't work outside of VisualStudio

@cpyfferoen cpyfferoen changed the title Dotnet Core - Azure Pipelines Build Azure Pipelines Build/VisualStudio DesignTime magic Sep 17, 2019
@cpyfferoen
Copy link
Author

No combination of <Abstract/> <Antlr4AbstractGrammar/> or a host of other settings will produce, using the dotnet CLI (dotnet build or dotnet msbuild), tokens for any grammar that has an Imports in it. Possibly this is related to #111 - but as soon as I start visual studio (don't even build or click any buttons) bamm! It generates the *.tokens file for my partials, and everything works there after..

@cpyfferoen
Copy link
Author

Workaround (aka cheating):

- task: DotNetCoreCLI@2
  displayName: 'dotnet msbuild $(project)'
  continueOnError: true
  inputs:
    command: 'custom'
    projects: '$(project)'
    custom: 'msbuild'
    arguments: '/p:DesignTimeBuild=true /p:Configuration=$(buildConfiguration)'
# yes, the above task fails.. so build again!!!
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '$(project)'
    arguments: '-c $(buildConfiguration)'

and the powershell to achieve same result

dotnet restore
dotnet msbuild /p:DesignTimeBuild=true
dotnet build

@sharwell
Copy link
Member

sharwell commented Oct 10, 2019

Can you create a minimal project to reproduce this, and submit it as a pull request to https://github.com/tunnelvisionlabs/antlr-integration-tests-csharp? I expect the pull request to initially fail, at which point I can work to find a solution to it.

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

No branches or pull requests

2 participants