Search code examples
buildbuild-automationdefinition

What exactly is 'Building'?


In IDEs, you can compile source code into machine code. You can debug a program, which means stepping through the program and looking for errors. But what does building a program achieve? In VS, I'm aware that when you build a program it produces an executable file in a debug folder.


Solution

  • This does not necessarily bear on what humans mean about 'build', but as far as MSBuild 2.0 is concerned, the code in Microsoft.Common.targets describes it thusly:

    ...
    <!--
    ============================================================
                                        Build
    
    The main build entry point.
    ============================================================
    -->
    <PropertyGroup>
        <BuildDependsOn>
            BeforeBuild;
            CoreBuild;
            AfterBuild
        </BuildDependsOn>
    </PropertyGroup>
    <Target
        Name="Build"
        Condition=" '$(_InvalidConfigurationWarning)' != 'true' "
        DependsOnTargets="$(BuildDependsOn)"
        Outputs="$(TargetPath)"/>
    
    <!--
    ============================================================
                                        BeforeBuild
    
    Redefine this target in your project in order to run tasks just before Build
    ============================================================
    -->
    <Target Name="BeforeBuild"/>
    
    <!--
    ============================================================
                                        AfterBuild
    
    Redefine this target in your project in order to run tasks just after Build 
    ============================================================
    -->
    <Target Name="AfterBuild"/>
    
    <!--
    ============================================================
                                        CoreBuild
    
    The core build step calls each of the build targets.
    ============================================================
    -->
    <PropertyGroup>
        <CoreBuildDependsOn>
              BuildOnlySettings;
              PrepareForBuild;
              PreBuildEvent;
              UnmanagedUnregistration;
              ResolveReferences;
              PrepareResources;
              ResolveKeySource;
              Compile;
              GenerateSerializationAssemblies;
              CreateSatelliteAssemblies;
              GenerateManifests;
              GetTargetPath;
              PrepareForRun;
              UnmanagedRegistration;
              IncrementalClean;
              PostBuildEvent
        </CoreBuildDependsOn>
    </PropertyGroup>
    <Target
        Name="CoreBuild"
        DependsOnTargets="$(CoreBuildDependsOn)">
    
        <OnError ExecuteTargets="_TimeStampAfterCompile;PostBuildEvent" Condition="'$(RunPostBuildEvent)'=='Always' or '$(RunPostBuildEvent)'=='OnOutputUpdated'"/>
        <OnError ExecuteTargets="_CleanRecordFileWrites"/>
    
    </Target>
    ...
    

    which suggests that 'build' mean roughly "compile plus all the associated auxiliary events that get you from code artifacts to a deployable result".