© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
13 replies
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>
<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>
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ using from another csproj
C#CC# / help
3y ago
✅ Local csproj
C#CC# / help
11mo ago
Configure .csproj
C#CC# / help
11mo ago
.Csproj problems
C#CC# / help
2y ago