msbuildpublishitemgroup

ItemGroup not picked up when publishing website via FTP


In my MSBuild, I created an item group, like the following:

<ItemGroup>
    <SomeFileType  Include="dir/file1.ext" />
    <SomeFileType  Include="dir/file2.ext" />
    <SomeFileType  Include="dir/file3.ext" />
</ItemGroup>

Then I try to publish the website via FTP. This item group above doesn't get picked up unless I change "SomeFileType" to "Content".

The reason why I want to use a custom name is that later in the build file I need to reference this collection of files using @(SomeFileType).

Do you have any idea to accomplish both uploading the files and being able to reference this group of items?

Thanks!

P.S. I also tried to add the following to make sure all the files can be picked up.

<Content Include="dir/*.ext" />

But this solution is not ideal. First, it covers all the files. Second, in my solution explorer, some files show up twice.


Solution

  • What happens if you try instead:

    <Content Include="@(SomeFileType)" />
    

    You get to still refer to them separately, and you aren't using a wildcard.

    Try this to see if it prevents the files from showing up twice.

    <Content Include="@(SomeFileType)">
       <Visible>false</Visible>
    </Content>