C#C
C#3y ago
fooo1

❔ getting sensitive config from .csproj

I would like to get some env vars in csproj, however when defining them in an ItemGroup I get compilation errors - msbuild error: specify the name of the target.
Presumably it's something obvious, but I can't find it.. :
<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net7.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

<!--commenting this ItemGroup fixes the issue-->
    <ItemGroup>
        <Email__Host>smtp.gmail.com</Email__Host>
        <Email__UserName>$(EMAIL_USERNAME)</Email__UserName>
        <Email__Password>$(EMAIL_PASSWORD)</Email__Password>
    </ItemGroup>

    <ItemGroup>
      <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0-preview.2.23128.3" />
    </ItemGroup>

</Project>
Was this page helpful?