You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to generate RID-specific apphost.exe files for our project, which we do using following post-build step in project file (see full example in attachment)
<TargetName="BuildAppHosts"AfterTargets="Build"Condition=" '$(RID)' == '' ">
<ItemGroup>
<TFMInclude="$(TargetFrameworks)"Condition=" '$(TargetFramework)' == '' "Label="Build from VS" />
<TFMInclude="$(TargetFramework)"Condition=" '$(TargetFramework)' != '' "Label="Build from MSBUILD or dotnet" />
</ItemGroup>
<MSBuildProjects="$(MSBuildProjectFullPath)"Properties="RID=win-x86;Configuration=$(Configuration)"Targets="Build" />
<CopySourceFiles="<path to build results>\$(AssemblyName).exe"DestinationFiles="<path to main bin>\$(AssemblyName).win-x86.exe" />
<MSBuildProjects="$(MSBuildProjectFullPath)"Properties="RID=win-x64;Configuration=$(Configuration)"Targets="Build" />
<CopySourceFiles="<path to build results>\$(AssemblyName).exe"DestinationFiles="<path to main bin>\$(AssemblyName).win-x64.exe" />
</Target>
This works fine in default setup, but breaks when artifacts folder used.
First issue:
Now build with RID doesn't replace apphost.exe with one for current RID if file already exists. This could be workarounded by adding Delete file step, but then second issue arises.
Second issue:
If we delete apphost.exe on machine without SDK for target framework installed, it is not restored. E.g. we have net9.0 SDK and want to build for both net8.0 and net9.0 - it will fail with error like this:
##[error]C:\hostedtoolcache\windows\dotnet\sdk\9.0.101\Microsoft.Common.CurrentVersion.targets(5322,5): Error MSB3030: Could not copy the file "D:\a\1\s\.build\obj\LinqToDB.CLI\Azure\net6.0\apphost.exe" because it was not found.
Reason for that is failed condition evaluation for _CreateAppHost target because AppHostSourcePath property is empty:
Describe the bug
We need to generate RID-specific
apphost.exe
files for our project, which we do using following post-build step in project file (see full example in attachment)This works fine in default setup, but breaks when artifacts folder used.
First issue:
Now build with RID doesn't replace
apphost.exe
with one for current RID if file already exists. This could be workarounded by addingDelete
file step, but then second issue arises.Second issue:
If we delete apphost.exe on machine without SDK for target framework installed, it is not restored. E.g. we have
net9.0
SDK and want to build for bothnet8.0
andnet9.0
- it will fail with error like this:Reason for that is failed condition evaluation for
_CreateAppHost
target becauseAppHostSourcePath
property is empty:https://github.com/dotnet/sdk/blob/v9.0.100/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.targets#L831
This property is empty, because it is initialized with
ResolvedAppHostPack.Path
propertyhttps://github.com/dotnet/sdk/blob/v9.0.100/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets#L337
Which is empty if SDK is not installed (
runtime
-only install doesn't help)There is
PathInPackage
property instead, which is not used by code abovehttps://github.com/dotnet/sdk/blob/v9.0.100/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets#L374
And yes, we cannot just install required SDKs as in that case we hit disk space limit during build on Azure DevOps...
To Reproduce
Test project. To switch between artifacts/non-artifacts build comment properties in Directory.Build.props
ResolvedAppHostPackBug.zip
Further technical details
dotnet --info
The text was updated successfully, but these errors were encountered: