-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate error if SelfContained Exe references framework dependent Exe, or vice versa #15117
Labels
breaking-change
Using this label will notify dotnet/compat and trigger a request to file a compat bug
Milestone
Comments
dsplaisted
added
the
breaking-change
Using this label will notify dotnet/compat and trigger a request to file a compat bug
label
Dec 30, 2020
dsplaisted
added a commit
to dsplaisted/sdk
that referenced
this issue
Dec 31, 2020
This was referenced Dec 31, 2020
Merged
Forgind
pushed a commit
to dotnet/msbuild
that referenced
this issue
Feb 3, 2021
…jects (#5994) This allows additional properties to be gathered from project references via the project reference protocol. This is in order to support generating an error when a self-contained Executable references a non-SelfContained Executable, or vice versa, as described in dotnet/sdk#15117. The referenced project can declare what additional properties should be gathered with AdditionalTargetFrameworkInfoProperty items: <ItemGroup> <AdditionalTargetFrameworkInfoProperty Include="SelfContained"/> <AdditionalTargetFrameworkInfoProperty Include="_IsExecutable"/> </ItemGroup> These items will then be included in the AdditionalPropertiesFromProject metadata on the _MSBuildProjectReferenceExistent items. This value will have PropertyName=PropertyValue combinations joined by semicolons, and those sets of properties for the different TargetFramework values will be joined by double semicolons. For example, a project multitargeted to two TargetFrameworks may have the following for the AdditionalPropertiesFromProject metadata: SelfContained=true;_IsExecutable=true;;SelfContained=false;_IsExecutable=true Finding the right set of properties from the referenced project will required looking up the index of the NearestTargetFramework in the TargetFrameworks, and using that index to select the set of properties in the AdditionalPropertiesFromProject metadata. For example: string nearestTargetFramework = project.GetMetadata("NearestTargetFramework"); int targetFrameworkIndex = project.GetMetadata("TargetFrameworks").Split(';').ToList().IndexOf(nearestTargetFramework); string projectAdditionalPropertiesMetadata = project.GetMetadata("AdditionalPropertiesFromProject").Split(new[] { ";;" }, StringSplitOptions.None)[targetFrameworkIndex]; Dictionary<string, string> projectAdditionalProperties = new(StringComparer.OrdinalIgnoreCase); foreach (var propAndValue in projectAdditionalPropertiesMetadata.Split(';')) { var split = propAndValue.Split('='); projectAdditionalProperties[split[0]] = split[1]; } This is implemented in dotnet/sdk#15134.
dsplaisted
added a commit
to dsplaisted/sdk
that referenced
this issue
Apr 22, 2021
23 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
breaking-change
Using this label will notify dotnet/compat and trigger a request to file a compat bug
With #14488, we will support Exe projects referencing Exe projects, and both apps should be runnable from the referencing project's output folder. However, the apps won't run correctly work if one of them is self-contained and the other isn't (due to how hostfxr works). So we should generate an error if a self-contained Exe references a framework dependent Exe, or vice versa.
This error should be suppressible in case there are Exe projects that want to reference other Exe projects where SelfContained doesn't match, but they don't want a runnable output of the referenced project, they just want to call APIs from that assembly. Also adding this error message will be a potentially breaking change that we should document.
The text was updated successfully, but these errors were encountered: