Fix DefaultItemExcludes handling in XSharp.SDK.Props - #2075
Open
hpetriffer wants to merge 2 commits into
Open
Conversation
XSharp.SDK.Props assigned DefaultItemExcludes instead of appending to it, so any value the user had set in Directory.Build.props was silently discarded for .xsproj projects. Microsoft.NET.Sdk.DefaultItems.props always appends, so DefaultItemExcludes works as documented for C# and VB but not for X#. Prepend $(DefaultItemExcludes) to the assignment. The .NET SDK adds its own entries (BaseOutputPath, BaseIntermediateOutputPath, publish, **/*.user) after this file is imported, so the only values picked up by the prefix are the ones the user set explicitly. Co-Authored-By: Claude Opus 5 <[email protected]>
The item globs owned by the X# SDK (VOBinary, NativeResource, Compile for *.designer.prg and *.xaml.prg, EmbeddedResource, None, ApplicationDefinition) carried no Exclude attribute, so they reached into obj\ and bin\ as well. Stale generated files there are picked up as project items, which surfaces as XS0579/CS0579 "Duplicate attribute" whenever an intermediate directory from an earlier configuration is still on disk. Add Exclude="$(XSharpDefaultItemExcludes)" to those globs. The property is computed before the item types owned by X# are appended to DefaultItemExcludes, because the appended value would exclude exactly the files these globs are meant to collect. The output directories are listed explicitly: the .NET SDK adds them to DefaultItemExcludes only after this file is imported, which is too late for these globs. Empty-value guards keep a bare "/**" pattern from being formed. Co-Authored-By: Claude Opus 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent defects in
XSharp.SDK.PropsBoth were found while tracking down sporadic
XS9014/XS9019errors in a solution where a classic and an SDK-style project share one directory. Each commit stands on its own.1.
DefaultItemExcludesis assigned, not appendedMicrosoft.NET.Sdk.DefaultItems.propsalways writes$(DefaultItemExcludes);…. Here the inherited value is dropped, so anything a user sets inDirectory.Build.propsis silently ignored for.xsprojwhile it works as documented for.csproj. That is a surprising difference to debug — nothing fails, the setting just has no effect.Evaluation order confirms the fix is narrow: with
-v:diagon a real project, the final value contains the X# list followed by$(BaseOutputPath)/**,$(BaseIntermediateOutputPath)/**,publish/**,**/*.user. Those come from the .NET SDK, which is imported after this file, so the prefix picks up user values only.2. The X# item globs have no
ExcludeThese reach into
obj\andbin\. Any generated file left there from an earlier configuration becomes a project item, which shows up asXS0579/CS0579Duplicate attribute. It is easy to hit wheneverIntermediateOutputPathchanges and the old directory stays on disk.Exclude="$(XSharpDefaultItemExcludes)"is added to all seven globs. Two details worth reviewing:DefaultItemExcludes. Using the appended value would exclude exactly the files these globs are meant to collect.DefaultItemExcludesonly after this file is imported — too late for these globs.Condition="'$(BaseOutputPath)' != ''"guards keep a bare/**from being formed.$(DefaultExcludesInProjectFolder)is referenced although it is still empty at this point, so the value is picked up should the import order ever change.Verification
The file was evaluated standalone against a directory tree with decoys in
obj\Debug\andbin\Debug\:Not verified inside a full SDK build — that needs the file deployed to
C:\Program Files (x86)\XSharp\MSBuild\. The import-order assumptions above are taken from a-v:diagevaluation of a real.xsproj.Not included
The same
ItemGroupalso ignores$(EnableDefaultItems)and the per-type switches (EnableDefaultCompileItems,EnableDefaultEmbeddedResourceItems, …); the .NET SDK guards every default item group with them. Fixing that removes items from projects that setEnableDefaultItems=falseand rely on the current behaviour, so it is left out here and is worth its own discussion.