This might be relevant: https://stackoverflow.com/a/28874918/30225
> While conditional import statements work in command-line MSBuilds, > they do not work with MSBuild in the Visual Studio integrated > development environment (IDE). Conditional imports are evaluated by > using the configuration and platform values that are set when the > project is loaded. If changes are subsequently made that require a > reevaluation of the conditionals in the project file, for example, > changing the platform, Visual Studio reevaluates the conditions on > properties and items, but not on imports. Because the import > conditional is not reevaluated, the import is skipped. To work around > this, put conditional imports in the .targets files or put code in a > conditional block such as a Choose Element (MSBuild) block. I think this is true for `ItemGroup` element also... regards, Preet, in Auckland NZ On Wed, 11 Aug 2021 at 18:52, Greg Keogh <gfke...@gmail.com> wrote: > Folks, I need to publish different *.js files depending upon the selected > $(Configuration). I have VS2019 configs for Debug, AU region and US region. > I tried editing the csproj file to have conditions around the files, like > this fragment for the US. > > <ItemGroup Condition="'$(Configuration)'=='Release US'"> > <Content Include="wwwroot\script\app-us.js"/> > </ItemGroup> > > It does nothing, so I tried <None Remove> and <Content Remove> and > CopyToPublishDirectory in a dozen combinations, but I either get no files > or all files. I'm clearly bumbling around uselessly, so maybe someone has > done this before and can reveal what tricks are required. > > I'm just using VS2019 publish project command, so that's when I want the > conditions to run. Maybe ItemGroup conditions are meaningless for publish? > I dunno because web searches produce confusing and contradictory samples > and the MSDN documentation doesn't seem to cover what I'm doing. > > Thanks, > *Greg* >