msbuild icon indicating copy to clipboard operation
msbuild copied to clipboard

Document folder element in XSD

Open rokonec opened this issue 1 year ago • 3 comments

Gordon noticed we have it undocumented. After some research we believed it is relicd of past and shall be deleted.

But later, thanks to Kalle, we realized, VS uses it to mark empty folders.

image

Such mark is removed by VS as soon as you add file to it, and created when folder becomes empty.

Please document in xsd "Used by Visual Studio for empty folders." or something like this.

Related xsd location: https://github.com/dotnet/msbuild/blob/0d8d09e5c582526daeb4af0b52956c3290e424d1/src/MSBuild/MSBuild/Microsoft.Build.CommonTypes.xsd#L1161

rokonec avatar Feb 09 '24 14:02 rokonec

Visual Studio adds a Folder item in a csproj file if you create a folder in Solution Explorer and it doesn't yet contain any files that are included in the project. It would be unfortunate if the schema considered these elements invalid.

KalleOlaviNiemitalo avatar Feb 09 '24 15:02 KalleOlaviNiemitalo

Ah great, thanks for letting us know!

Note that the schema doesn't consider anything valid or invalid--you're welcome to define whatever items you want in your project and that shouldn't cause errors. The XSD controls VS intellisense and hover information.

Now that we understand this we should add some hover information to it :)

rainersigwald avatar Feb 09 '24 15:02 rainersigwald

Huh, if I add a custom item type to a csproj file, then Visual Studio indeed does not mark that as invalid in any way. But if I change the file name extension from csproj to xml and edit the file in Visual Studio again, then I do get a wavy blue underline and a warning in the Error List pane:

The element 'ItemGroup' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003' has invalid child element 'SomethingCustom' in namespace 'http://schemas.microsoft.com/developer/msbuild/2003'. List of possible elements expected: 'Item, Reference, SDKReference, COMReference, COMFileReference, PackageReference, DotNetCliToolReference, Xdcmake, Bscmake, ClCompile, ClInclude, Midl, ResourceCompile, PreLinkEvent, CustomBuildStep, Manifest, ProjectConfiguration, ProjectCapability, NativeReference, ProjectReference, Compile, EmbeddedResource, Content, Page, Resource, ApplicationDefinition, None, BaseApplicationManifest, Folder, Import, Service, WebReferences, WebReferenceUrl, FileAssociation, BootstrapperFile, PublishFile, TargetPlatform, Analyzer, CodeAnalysisDependentAssemblyPaths, CodeAnalysisDictionary, CodeAnalysisImport, AppxManifestSchema, StoreManifestSchema, AppxHashUri, PRIResource, AppxSystemBinary, AppxReservedFileName, AppxManifestFileNameQuery, AppxManifestImageFileNameQuery, AppxManifest, StoreAssociationFile, AppxManifestMetadata, PlatformVersionDescription, AppxPackagePayload, ComFilesOutputGroupOutputs, CopyWinmdArtifactsOutputGroupOutputs, CopyLocalFilesOutputGroupOutput, _PackagingOutputsUnexpanded, _GetResolvedSDKRef....

So, it seems the schema does not allow custom elements, but Visual Studio suppresses those violations when it knows it's editing a project file.

KalleOlaviNiemitalo avatar Feb 09 '24 15:02 KalleOlaviNiemitalo