Ctrl K
ComunidadGuías…

Directory.Build.props

Rama main · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
<?xml version="1.0" encoding="utf-8"?>
<Project>
    <PropertyGroup>
        <!-- Local-dev placeholder, never bumped by hand. The release pipeline stamps
             -p:Version from the tag (scripts/release-prepare.sh). Other CI builds do not.
             InformationalVersion is deliberately NOT set — it defaults to the effective
             Version (+ source commit SHA via SourceLink). -->
        <Version>0.0.0-local</Version>
    </PropertyGroup>

    <!-- Only Endatix.Api is read by GET /api/system/version. A git checkout that is not a
         release reports its branch; a release line (main, hotfix/*, or a detached tag checkout)
         sitting exactly on a clean v* tag reports that tag. A dirty tree is not that release.
         No git (the Dockerfile, a CI build that does not pass -p:Version): version stays null
         and there is no branch. SourceLink appends the commit when it has one. -->
    <Target Name="ResolveLocalVersion" BeforeTargets="GetAssemblyVersion"
            Condition="'$(Version)' == '0.0.0-local' And '$(MSBuildProjectName)' == 'Endatix.Api'">
        <!-- Exec uses cmd.exe on Windows. /dev/null is not a path there, so the redirect fails and IgnoreExitCode hides it. -->
        <PropertyGroup>
            <_NullDevice Condition="$([MSBuild]::IsOSPlatform('Windows'))">nul</_NullDevice>
            <_NullDevice Condition="'$(_NullDevice)' == ''">/dev/null</_NullDevice>
        </PropertyGroup>
        <Exec Command="git symbolic-ref --short -q HEAD 2&gt;$(_NullDevice)"
              WorkingDirectory="$(MSBuildThisFileDirectory)" ConsoleToMSBuild="true" IgnoreExitCode="true"
              IgnoreStandardErrorWarningFormat="true"
              StandardOutputImportance="low" StandardErrorImportance="low">
            <Output TaskParameter="ConsoleOutput" PropertyName="_LocalGitBranch" />
            <Output TaskParameter="ExitCode" PropertyName="_LocalGitBranchExitCode" />
        </Exec>
        <PropertyGroup>
            <_LocalGitBranch Condition="'$(_LocalGitBranchExitCode)' != '0'"></_LocalGitBranch>
            <!-- Detached GitHub Actions checkout. A tag ref is not a branch: GITHUB_REF_NAME is the tag. -->
            <_LocalGitBranch Condition="'$(_LocalGitBranch)' == '' And '$(GITHUB_REF_TYPE)' == 'branch' And '$(GITHUB_HEAD_REF)' != ''">$(GITHUB_HEAD_REF)</_LocalGitBranch>
            <_LocalGitBranch Condition="'$(_LocalGitBranch)' == '' And '$(GITHUB_REF_TYPE)' == 'branch'">$(GITHUB_REF_NAME)</_LocalGitBranch>
            <_LocalGitBranch>$(_LocalGitBranch.Trim())</_LocalGitBranch>
            <_LocalIsReleaseLine Condition="'$(_LocalGitBranch)' == '' Or $(_LocalGitBranch.Equals('main')) Or $(_LocalGitBranch.StartsWith('hotfix/'))">true</_LocalIsReleaseLine>
        </PropertyGroup>
        <Exec Condition="'$(_LocalIsReleaseLine)' == 'true'"
              Command="git describe --tags --exact-match --dirty --match &quot;v[0-9]*&quot; 2&gt;$(_NullDevice)"
              WorkingDirectory="$(MSBuildThisFileDirectory)" ConsoleToMSBuild="true" IgnoreExitCode="true"
              IgnoreStandardErrorWarningFormat="true"
              StandardOutputImportance="low" StandardErrorImportance="low">
            <Output TaskParameter="ConsoleOutput" PropertyName="_LocalGitTag" />
            <Output TaskParameter="ExitCode" PropertyName="_LocalGitTagExitCode" />
        </Exec>
        <PropertyGroup Condition="'$(_LocalGitTagExitCode)' == '0' And '$(_LocalGitTag)' != '' And !$(_LocalGitTag.Contains('-dirty'))">
            <InformationalVersion>$(_LocalGitTag.Trim().TrimStart('v'))</InformationalVersion>
        </PropertyGroup>
        <ItemGroup Condition="'$(InformationalVersion)' == '' And '$(_LocalGitBranch)' != ''">
            <AssemblyMetadata Include="GitBranch" Value="$(_LocalGitBranch)" />
        </ItemGroup>
    </Target>

    <PropertyGroup>
        <TargetFramework>net10.0</TargetFramework>
        <!-- GHSA-w3x6-4m5h-cxqf (10.0.6+) and GHSA-p3jp-9v83-76w9 (ILCompiler 10.0.14+). -->
        <RuntimeFrameworkVersion>10.0.14</RuntimeFrameworkVersion>
        <LangVersion>14</LangVersion>
        <NeutralLanguage>en-US</NeutralLanguage>
        <Nullable>enable</Nullable>
        <!-- SonarCloud imports nullable warnings from the build; a new one fails it instead. -->
        <WarningsAsErrors>$(WarningsAsErrors);nullable</WarningsAsErrors>
        <ImplicitUsings>enable</ImplicitUsings>
        <GenerateDocumentationFile>true</GenerateDocumentationFile>
        <WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
        <!-- Explicit NuGet audit policy (net10 defaults: Mode=all, Level=low). Pin so the
             ratchet is reviewable and does not silently change with the SDK. -->
        <NuGetAudit>true</NuGetAudit>
        <NuGetAuditMode>all</NuGetAuditMode>
        <NuGetAuditLevel>low</NuGetAuditLevel>
    </PropertyGroup>

    <!-- GitHub Actions / most CI runners set CI=true. Map it so ContinuousIntegrationBuild
         (and the NU1903/NU1904 ratchet below) apply without every workflow repeating -p:. -->
    <PropertyGroup Condition="'$(CI)' == 'true' And '$(ContinuousIntegrationBuild)' == ''">
        <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
    </PropertyGroup>

    <!-- Stage 1: high/critical vulnerable packages fail CI only; local restore stays warnings.
         NU1901/NU1902 stay warnings until triage capacity after docs npm batches. -->
    <PropertyGroup Condition="'$(ContinuousIntegrationBuild)' == 'true'">
        <WarningsAsErrors>$(WarningsAsErrors);NU1903;NU1904</WarningsAsErrors>
    </PropertyGroup>

    <!-- Lift transitive vulnerable Pkcs (SqlClient / OpenXml / etc.) to the CPM pin; do not flow into packed deps. -->
    <ItemGroup>
        <PackageReference Include="System.Security.Cryptography.Pkcs">
            <PrivateAssets>all</PrivateAssets>
        </PackageReference>
    </ItemGroup>

    <PropertyGroup>
        <NSubstitutePublicKey>0024000004800000940000000602000000240000525341310004000001000100c547cac37abd99c8db225ef2f6c8a3602f3b3606cc9891605d02baa56104f4cfc0734aa39b93bf7852f7d9266654753cc297e7d2edfe0bac1cdcf9f717241550e0a7b191195b7667bb4f64bcb8e2121380fd1d9d46ad2d92d2d15605093924cceaf74c4861eff62abf69b9291ed0a340e113be11e6a7d3113e92484cf7045cc7</NSubstitutePublicKey>
    </PropertyGroup>

    <PropertyGroup>
        <Company>Endatix, Ltd.</Company>
        <Authors>Endatix team and Community contributors</Authors>
        <Owners>Endatix team and Community contributors</Owners>
        <Copyright>Copyright © Endatix, Ltd. $([System.DateTime]::Today.ToString('yyyy'))</Copyright>
        <Product>Endatix Platform</Product>
        <PackageProjectUrl>https://endatix.com</PackageProjectUrl>
        <PackageIcon>icon.png</PackageIcon>
        <PackageReadmeFile>README.md</PackageReadmeFile>
        <RepositoryUrl>https://github.com/endatix/endatix</RepositoryUrl>
        <PackageLicenseExpression>MIT</PackageLicenseExpression>
        <PackageTags>endatix,forms,open-source,data collection,data processing,data insights</PackageTags>
        <EndatixPlatformDescription>Endatix Platform is an open-source data collection and management library for .NET.</EndatixPlatformDescription>
    </PropertyGroup>

    <ItemGroup>
        <None Include="$(MSBuildThisFileDirectory)/build/endatix-icon.png">
            <Pack>True</Pack>
            <PackagePath>icon.png</PackagePath>
        </None>
        <None Include="README.md">
            <Pack>True</Pack>
            <PackagePath>README.md</PackagePath>
        </None>
    </ItemGroup>

    <!-- SonarCloud runs its S-rules on src only (tests/** is excluded), so only non-test projects get
         them locally. They stay warnings. Item conditions see IsTestProject from tests/Directory.Build.props. -->
    <ItemGroup Condition="'$(IsTestProject)' != 'true'">
        <PackageReference Include="SonarAnalyzer.CSharp" PrivateAssets="all" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
    </ItemGroup>

    <PropertyGroup>
        <!-- https://devblogs.microsoft.com/visualstudio/vs-toolbox-accelerate-your-builds-of-sdk-style-net-projects/ -->
        <AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
    </PropertyGroup>
</Project>