none
Compile Separately For XAML files RRS feed

  • Question

  • Hello,

    I'm encountering some issues relations to XAML files. I hope you can help me.
    Currently, MSBuild will compile XAML files at during compiling process, and MSBuild will generate some files from XAML files like as: App.g.hpp, MainPage.g.hpp, XamlTypeInfo.g.cpp,... via MarkupCompilePass1 and MarkupCompilePass2 task, but my purpose is able to generate XamlTypeInfo.g.cpp file from XAML files, then using these file for an another custom build.
    So, I'm trying to compiling separately for XAML files to generating  XamlTypeInfo.g.cpp, but I can't find any ways to handle this issue.
    Here, Could anybody please help me or give me any ideas?

    Thank you for your time and attention

    Best Regards,
    Thuan


    Tuesday, September 3, 2019 12:14 PM

Answers

  • Hi Thuan_BKDN,

    According to your description, you can use the AfterBuild or BeforeBuild event in the xxxproj file.The MSBuild language is flexible and extensible.

    AfterBuild event will execute the command after the whole compilation.  You can refer to this article:

    https://stackoverflow.com/questions/6128567/visual-studio-project-file-difference-between-postbuildevent-and-afterbuild-targ

    About target event:

    https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-targets?view=vs-2019

    Just like this-------It is a similar example:

    <Target Name="AfterBuild">
     <MSBuild Projects ="xxxxxx (file location)" Properties="Configuration=Debug">
    
        <ItemGroup>
        <ClCompile Include="xxxxxx.cpp(the location of the file)" />
      </ItemGroup>
    
    </MSBuild>
    
    </Target>

    If this does not work or l misunderstand your issue, please share more information about the xml codes and the next custom build.

    Best Regards,

    Perry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    • Marked as answer by Thuan_BKDN Thursday, September 5, 2019 4:15 AM
    Wednesday, September 4, 2019 11:26 AM

All replies

  • Hi,

    XamlTypeInfo.g.cpp is automatically generated when you write code in Visual Studio.

    Although compiling XamlTypeInfo.g.cpp will slow down the build speed from the current evaluation, but there is currently no other way to compile XamlTypeInfo.g.cpp separately.

    Best regards.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, September 3, 2019 12:58 PM
  • Hi Richasy,

    "XamlTypeInfo.g.cpp is automatically generated when you write code in Visual Studio"

    Could you please tell me know for the details of your comment?

    Because I see when I try to changed any thing for xaml file, below files will be auto-generated: 
    xaml_file_name.g.h, XamlBindingInfo.g.h, XamlLibMetadataProvider.g.cpp, XamlTypeInfo.g.h, XamlTypeInfo.Impl.g.cpp
    But XamlTypeInfo.g.cpp only created when I building project to the during compiling process, based-on MarkupCompilePass2 task that XamlTypeInfo.g.cpp file will be generated.




    Best Regards,
    Thuan


    • Edited by Thuan_BKDN Wednesday, September 4, 2019 11:44 AM
    Wednesday, September 4, 2019 1:58 AM
  • Hi ,

    Since the problem is more related to MSBuild, I'll help you to move this thread to the MSBuild Forum. You could get more professional support there.

    Thank you for your patience.

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, September 4, 2019 7:41 AM
  • Hi Thuan_BKDN,

    According to your description, you can use the AfterBuild or BeforeBuild event in the xxxproj file.The MSBuild language is flexible and extensible.

    AfterBuild event will execute the command after the whole compilation.  You can refer to this article:

    https://stackoverflow.com/questions/6128567/visual-studio-project-file-difference-between-postbuildevent-and-afterbuild-targ

    About target event:

    https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-targets?view=vs-2019

    Just like this-------It is a similar example:

    <Target Name="AfterBuild">
     <MSBuild Projects ="xxxxxx (file location)" Properties="Configuration=Debug">
    
        <ItemGroup>
        <ClCompile Include="xxxxxx.cpp(the location of the file)" />
      </ItemGroup>
    
    </MSBuild>
    
    </Target>

    If this does not work or l misunderstand your issue, please share more information about the xml codes and the next custom build.

    Best Regards,

    Perry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    • Marked as answer by Thuan_BKDN Thursday, September 5, 2019 4:15 AM
    Wednesday, September 4, 2019 11:26 AM
  • Hi Perry, Roy
    Thanks for your support

    sorry for the above confusing description.


    My purpose is able to generate correct for XamlTypeInfo.g.cpp file via MarkupCompilePass2 task. 
    So, I'm wanting pre-build the process to compile xaml files before MSbuild starting to build project.
    As I know, currently MSbuild integrated XAML Compiler as a part, and when MSbuild starting to compile for xaml files, MSbuild will through the order of below tasks: 
    MarkupCompilePass1 -> CreateWinMD -> ComputeGeneratedWinMD -> MarkupCompilePass2
    At MarkupCompilePass2, XamlTypeInfo.g.cpp correct file will be generated along with some *.hpp files: xaml_file_name.g.hpp

    So, Could you please tell me know I can pre-build the process to compile xaml files before MSbuild starting to build project?

    Thanks you,


    Best Regards,
    Thuan

    • Edited by Thuan_BKDN Thursday, September 5, 2019 3:50 AM
    Thursday, September 5, 2019 3:48 AM
  • Hi,

    It seems that I found the answer, to simple to able to pre-build the process to compile xaml files before MSbuild starting to build project.
    Some suggestions of Perry that help me, thanks Perry.
    The below document will help to resolved my issue: 
    https://docs.microsoft.com/en-us/visualstudio/msbuild/how-to-specify-which-target-to-build-first?view=vs-2019

    Again, thanks for all the answer here.

    Best Regards,
    Thuan
    Thursday, September 5, 2019 4:14 AM