© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
3 replies
skyslide22

✅ .csproj – how to generate nodes dynamically by iterating over a string array ?

how can i generate xml code in the .csproj file? i dont want to repeat my actions 10000 times...
so i got a list of strings i want to insert in some xml nodes:

    my-items = 
        Utils\**\*.*;
        Settings\**\*.*;
        Extensions\**\*.*;
        Components\**\*;
        Templates\**\*;
    
    foreach item in my-items
    do
    <ItemGroup>
        <None Include="@item">
          <Link>@item\%(RecursiveDir)/%(FileName)%(Extension)</Link>
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
    </ItemGroup>
    end
    my-items = 
        Utils\**\*.*;
        Settings\**\*.*;
        Extensions\**\*.*;
        Components\**\*;
        Templates\**\*;
    
    foreach item in my-items
    do
    <ItemGroup>
        <None Include="@item">
          <Link>@item\%(RecursiveDir)/%(FileName)%(Extension)</Link>
          <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
    </ItemGroup>
    end
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

Iterating over AsyncEnumerable and writing to MemoryStream
C#CC# / help
3y ago
.NET EF - How to generate a new database in runtime (dynamically)?
C#CC# / help
2y ago
How to generate a unique int from an arbitrary string?
C#CC# / help
8mo ago
❔ Is there an easy way to serialize a Dictionary<string, string> to XML nodes?
C#CC# / help
4y ago