Question

Is it possible to do a wildcard import like:

<Import Project = "*.settings" />

Like we normal do with items?:

<ItemGroup>
  <Files Include = "*.cs"/>
</ItemGroup>

We have been trying but we get the following error:

error MSB4025: The project file could not be loaded. Root element is missing.

*.settings files simply contain a list of property values that we build using some other tool. It contains no targets at all. Basically, we want to inject our build project with property values generated from another tool and we don't want to manually (or automatically) update our build project file with new values.

Was it helpful?

Solution

It's definitely ok to import multiple files like that. The problem is not with the Import but as the error says with your imported project. The error basically means one or more of your .settings files contain invalid xml. The files must look like this for example:

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <A>a</A>
    <B>a</B>
  </PropertyGroup>
</Project>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top