Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

529
Visualizações
How to see c# code compiled from Razor component with VS2022 in project targeting .Net6?

I have a component and I want to see generated by RazorSourceGenerator *_razor.g.cs file.

Previously with VS2019 and .Net5 I could open the "\obj\Debug\net5.0\Razor\Pages" folder and found the generated files there.

Now, If I have some compillation error in *.razor component I can see a error message with refers to the "\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator" folder but there is no such folder. It seems it is deleted after the project has build.

Is there way to preserve this folder to see the *.razor file compillation result?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You can set the property EmitCompilerGeneratedFiles to true in your csproj.

This is a good write-up of how it works and the options for where the files get written

over 4 years ago · Santiago Trujillo Relatório

0

Thank you Mister Maggo for pointing to the article. Let me post full answer.

To preserve generated *_razor.g.cs files set the EmitCompilerGeneratedFiles property in the project file. But in this case you will not be able to see generated code by double clicking on error in Output or Error List window because files will be saved into

obj\Debug\generated\Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator

forlder. But the error will refer to

Microsoft.NET.Sdk.Razor.SourceGenerators\Microsoft.NET.Sdk.Razor.SourceGenerators.RazorSourceGenerator\

folder. So you need to specify that files should be preserved in this folder by setting the CompilerGeneratedFilesOutputPath property.

So, the short anser is to add this into your project file in the project section:

  <PropertyGroup>
    <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
    <CompilerGeneratedFilesOutputPath>.</CompilerGeneratedFilesOutputPath>
  </PropertyGroup>
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda