Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 785919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:57:17+00:00 2026-05-14T20:57:17+00:00

I created the ItemGroup shown in the code snippet. I need to iterate through

  • 0

I created the ItemGroup shown in the code snippet. I need to iterate through this ItemGroup and run the EXEC command – also shown in the code snippet. I cannot seem to get it to work. The code returns the error shown below (note – the Message is written 2 times, which is correct), but the EXEC Command is not running correctly. The value is not being set; therefore the EXEC is not executing at all. I need the EXEC to execute twice or by however sections I define in the ItemGroup.

ERROR:
Encrypting WebServer appSettings section
Encrypting WebServer connectionStrings section
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -pef “” “\gaw\UI” -prov “RSACustomProvider”
Encrypting configuration section…
The configuration section ” was not found.

CODE SNIPPET:

<ItemGroup>
    <SectionsToEncrypt Include="Item">
      <Section>appSettings</Section>     
    </SectionsToEncrypt>
    <SectionsToEncrypt Include="Item">     
      <Section>connectionStrings</Section>
    </SectionsToEncrypt>  
  </ItemGroup>

  <Target Name="EncryptWebServerWebConfigSections">   
    <Message Text="Encrypting WebServer %(SectionsToEncrypt.Section) section" />

    <Exec Command="$(AspNetRegIis) -pef &quot;%(SectionsToEncrypt.Section)&quot; &quot;$(DropLocation)\$(BuildNumber)\%(ConfigurationToBuild.FlavorToBuild)\$(AnythingPastFlavorToBuild)&quot; -prov &quot;$(WebSiteRSACustomProviderName)&quot;"/>
  </Target>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:57:18+00:00Added an answer on May 14, 2026 at 8:57 pm

    The problem is that you are batching on 2 items at a time. What I mean is the you have the statements

    %(SectionsToEncrypt.Section)
    %(ConfigurationToBuild.FlavorToBuild)
    

    In the same task invocation. When you batch on more than 1 item at a time in the same task invocation, they will be batch independently. That’s why you’re error is stating The configuration section ” …

    If you your FlavorToBuild just has one value what you should do is to stuff that into a property before you call to Exec and then use the property. So your one liner would then convert to:

    <PropertyGroup>
        <_FlavToBuild>%(ConfigurationToBuild.FlavorToBuild)<_FlavToBuild>
    </PropertyGroup>
    <Exec Command="$(AspNetRegIis) -pef &quot;%(SectionsToEncrypt.Section)&quot; &quot;$(DropLocation)\$(BuildNumber)\$(_FlavToBuild)\$(AnythingPastFlavorToBuild)&quot; -prov &quot;$(WebSiteRSACustomProviderName)&quot;"/>
    

    If you have multiple values for FlavorToBuild then it’s more complicated. You would have 2 options:

    1. Hard code Exec more than once
    2. Use target batching with task batching to perform the foreach/foreach

    Batching is one of the most confusing elements of MSBuild. I’ve put together some online resources at http://sedotech.com/Resources#batching. If you want to know more than that then you can pick up a copy of my book.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.