Open BinToss opened 9 months ago
If we don't specify a target framework when TargetFrameworks
is defined, MSBuild...vomits on itself.
dotnet build -getProperty:intermediateOutputPath -getItem:AvaloniaXaml --framework net8.0
{
"Properties": {
"intermediateOutputPath": "obj\\Debug\\net8.0\\"
},
"Items": {
"AvaloniaXaml": [
{
"Identity": "App.axaml",
"SubType": "Designer",
"FullPath": "C:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample\\App.axaml",
"RootDir": "C:\\",
"Filename": "App",
"Extension": ".axaml",
"RelativeDir": "",
"Directory": "Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample\\",
"RecursiveDir": "",
"ModifiedTime": "2024-02-01 22:30:18.0875806",
"CreatedTime": "2023-07-11 02:12:30.0670637",
"AccessedTime": "2024-02-13 01:02:37.8473098",
"DefiningProjectFullPath": "C:\\Users\\Noah\\.nuget\\packages\\avalonia\\11.0.7\\buildTransitive\\AvaloniaBuildTasks.props",
"DefiningProjectDirectory": "C:\\Users\\Noah\\.nuget\\packages\\avalonia\\11.0.7\\buildTransitive\\",
"DefiningProjectName": "AvaloniaBuildTasks",
"DefiningProjectExtension": ".props"
},
{
"Identity": "MainWindow.axaml",
"SubType": "Designer",
"FullPath": "C:\\Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample\\MainWindow.axaml",
"RootDir": "C:\\",
"Filename": "MainWindow",
"Extension": ".axaml",
"RelativeDir": "",
"Directory": "Repos\\BinToss\\GroupBox.Avalonia\\GroupBox.Avalonia.Sample\\",
"RecursiveDir": "",
"ModifiedTime": "2024-02-03 05:04:33.6008497",
"CreatedTime": "2023-07-11 02:12:30.1012734",
"AccessedTime": "2024-02-13 01:02:37.8473098",
"DefiningProjectFullPath": "C:\\Users\\Noah\\.nuget\\packages\\avalonia\\11.0.7\\buildTransitive\\AvaloniaBuildTasks.props",
"DefiningProjectDirectory": "C:\\Users\\Noah\\.nuget\\packages\\avalonia\\11.0.7\\buildTransitive\\",
"DefiningProjectName": "AvaloniaBuildTasks",
"DefiningProjectExtension": ".props"
}
]
}
}
dotnet build -getProperty:intermediateOutputPath -getItem:AvaloniaXaml
{
"Properties": {
"intermediateOutputPath": "obj\\Debug\\"
},
"Items": {
"AvaloniaXaml": []
}
}
Instead of parsing the project file (which may have its TargetFrameworks property defined in a separate file e.g. targetframeworks.props), I'd recommend
A. Use dotnet-build/MSBuild to evaluate the TargetFrameworks
property...
dotnet build -getProperty:TargetFrameworks
net6.0;net7.0;net8.0
B. Deserialize/stringify the contents of obj/project.assets.json
, access targets
or project.frameworks
, and parse the names of either one's properties for the target frameworks recently evaluated by dotnet-build/MSBuild. There's a high chance at least assets for at least one of those targets has been built in obj
.
Describe the bug
This is one of the causes of the repeated "Previewer is not available. Build the project first." prompt.
Many of the MSBuild properties evaluated and required by this extension are dependent on the singular
TargetFramework
property being defined and valid. Properties such asTargetPath
and AvaloniaPreviewerNetCoreToolPath. However, this property and the pluralTargetFrameworks
are mutually exclusive. Defining both in the same project silently breaks things.Note: Given
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
anddotnet build multiTargeting.csproj
, dotnet will build binaries for each target framework i.e.obj/Debug/net6.0
,obj/Debug/net7.0
,bin/Debug/net6.0
,bin/Debug/net7.0
.To Reproduce
Avalonia for VS Code
v0.0.29
Avalonia version
11.0.6
VS Code version
v1.86.0
Relevant log output
Additional context
No response