Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

Build macros in VS 26 Aug 2022 06:23 #23487

  • JohnBonnett88
  • JohnBonnett88's Avatar
  • Topic Author


  • Posts: 39
  • Hi All,
    I am having a problem with defining some build macros for an X# project in VS2022, in particular where I want the output to go. When I select the Properties of the project and go to the Build tab, I see the snippet in attachment P1.

    Now I don't know what an Intermediate Output Path means or is, and I don't know what the macro names shown here are. They do not appear in the editor/browser you get when you click the three dots button at the right. So I change things to be what I want as shown in attachment P2.

    I build and I get, in the output window:

    Build started...
    Build started: Project: 1 bDefines, Configuration: Release Any CPU
    1 bDefines -> C:\Users\XVJBONNE\source\repos\LabPro\Release\1 bDefines.dll
    ========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========

    It has generated the output exactly where I wanted. I should be able to do this with two macros like this
    $(SolutionDir)$(ConfigurationName)
    but that does not seem to work. It puts the output in the folder one level higher for some reason.

    I close the solution, open it again and go to the same Properties/Build for the project again and what I see is back to P1 again.

    If I look at the project file in an external editor, it has an entry like this:

    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" Label="Configuration">
    <PlatformTarget>x86</PlatformTarget>
    <TreatWarningsAsErrors>False</TreatWarningsAsErrors>
    <EmitDebugInformation>false</EmitDebugInformation>
    <DebugType>pdbonly</DebugType>
    <OutputPath>$(SolutionDir)Release</OutputPath>

    and the OutputPath is just what I want, but is not what I see in VS.

    What is happening here?

    Best Regards,
    John Bonnett
    Attachments:

    Please Log in or Create an account to join the conversation.

    Last edit: by robert. Reason: Inserted images

    Build macros in VS 26 Aug 2022 09:47 #23489

    • robert
    • robert's Avatar


  • Posts: 3448
  • John,
    First: VS/MsBuild uses a 2 step approach when building. This usually involves the Obj and the Bin folder.
    The Obj folder is used to store the compilation result but also some intermediate files, such as compiled resources and cache files for dependency information. This folder also contains the generated source code for XAML files and other source code that is generated by the build system.
    After the compilation the compiled DLL, PDB and/or XML are copied to the output folder, along with any files that are marked as "copy to output".
    I am not sure why you are seeing the $(OutputPath) macro in the dialog. This is not correct. It should have returned exactly what you typed in. Which version of X# are you using ?

    If you leave the intermediate output path empty then the temp files will go to the obj\$(Configuration) folder under the project.

    The macro $(SolutionDir)$(ConfigurationName) is not correct. This should be $(SolutionDir)$(Configuration)

    Pro tip:
    You can also define your own properties in the project file.
    That is not possible through the Project Properties screen but you need to directly edit the XSProj file.
    For example in our VS integration system we are including a common file "Common.Props" in each project file
    <Import Project="$(SolutionDir)Tools\Common.props" Condition="'$(SolutionDir)'!=''" />

    In that Common.Props file we declare a lot of properties. A subset is shown below
    The full file can be seen here:
    github.com/X-Sharp/XSharpPublic/blob/mai...lStudio/Common.props
    <PropertyGroup>
    <VSTarget Condition=" '$(VSTarget)' == '' ">2019</VSTarget>
    .
    <BinariesDir>$(SolutionDir)Binaries\$(VSTarget)\</BinariesDir>
    <IntermediateOutputPath>$(BinariesDir)obj\$(Configuration)\$(ProjectName)\</IntermediateOutputPath>
    <OutputPath>$(BinariesDir)$(Configuration)\</OutputPath>
    .
    </PropertyGroup>

    In the projects inside the solution we are no longer declaring the OutPutPath and IntermediateOutputPath.
    These are all set in the included Common.Props file.That is very convenient.
    Of course you will have to edit these properties directly in the xsproj file then and do not use the property dialog.


    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Build macros in VS 30 Aug 2022 05:01 #23507

    • JohnBonnett88
    • JohnBonnett88's Avatar
    • Topic Author


  • Posts: 39
  • Hi Robert,

    Wow! Thankyou for such a comprehensive reply. I had discovered some of the things you mention in my digging around but X# seemed to be behaving rather differently than C#, which I also have in my solution, in particular that difference with ${Configuration} and ${ConfigurationName}. I only used ${ConfigurationName} because it appeared in the list of macros when I went to edit the output path. I didn't know why X# should be different, but thought I should follow that guidance.

    I will certainly look into that Common.Props, now that I know about it. I had noticed that menu option in X# projects that let you edit the project file directly, and the fact that C# does not have it.

    Thankyou again for all your effort and ongoing help.

    Best Regards,
    John

    Please Log in or Create an account to join the conversation.

    Build macros in VS 30 Aug 2022 05:43 #23508

    • JohnBonnett88
    • JohnBonnett88's Avatar
    • Topic Author


  • Posts: 39
  • Hi Robert,
    I noticed I did not reply to your question about version. I am on V1.12.2. I see there is a V2.13, but not quite public yet.
    John

    Please Log in or Create an account to join the conversation.

    Build macros in VS 09 Sep 2022 07:49 #23707

    • JohnBonnett88
    • JohnBonnett88's Avatar
    • Topic Author


  • Posts: 39
  • Hi All,

    I got my Release build outputs going where I wanted by manually editing my *.xsproj like this:

    The change was to make sure that, in the PropertyGroup that defines the Release build, you have the OutputPath defined as shown below.

    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'" Label="Configuration">

    <OutputPath>$(SolutionDir)$(Configuration)</OutputPath>

    </PropertyGroup>

    There are other lines in the group of course.

    Even though that macro $(Configuration) does not show up when you try to edit the output path in the Properties dialog in VS, it seems to do the what I wanted. In the dialog it still shows $(OutputPath)\ for that path, contrary to what is in the project file.

    Best Regards,
    John Bonnett

    Please Log in or Create an account to join the conversation.

    Build macros in VS 09 Sep 2022 13:27 #23712

    • robert
    • robert's Avatar


  • Posts: 3448
  • John,
    Can you send me your XsProj file so I can see what the problem is with the $(OutputPath) in the dialog ?

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Build macros in VS 15 Sep 2022 02:14 #23824

    • JohnBonnett88
    • JohnBonnett88's Avatar
    • Topic Author


  • Posts: 39
  • Hi Robert,

    Sorry I did not notice your reply earlier, but better late than never I suppose. I have attached one of my xsproj files, with the extension changed to keep the mail system happy.

    The project files were mostly just as the Xporter created, although I had to play with references quite a bit to get everything linked up as required. It was only recently, when I had got things to a clean build stage, that I needed to adjust where the outputs were going and play with build macros.

    Best Regards,
    John
    Attachments:

    Please Log in or Create an account to join the conversation.

    Build macros in VS 15 Sep 2022 07:57 #23831

    • robert
    • robert's Avatar


  • Posts: 3448
  • John,
    Did you forget to add the attachment ?

    Robert
    XSharp Development Team
    The Netherlands

    Please Log in or Create an account to join the conversation.

    Build macros in VS 20 Sep 2022 06:24 #23925

    • JohnBonnett88
    • JohnBonnett88's Avatar
    • Topic Author


  • Posts: 39
  • Yes I did. Should be now

    File Attachment:

    File Name: LabPro1.txt
    File Size:61 KB


    John
    Attachments:

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1