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
"dotnet restore" and "dotnet publish" use relative BaseIntermediateOutputPath even if it's set to absolute path (or $(SolutionDir) gets lost in the process somewhere).
It's possible that --artifacts-path is ignored as well. I have tried setting it explicitly, as well as /p:ArtifactsPath and <ArtifactsPath>...</ArtifactsPath> in Directory.Build.props, but same result.
To Reproduce
Create an empty solution
Add a .NET 8 GUI app project to it (into a subdirectory, i.e. src/<project-name>/)
Add a Directory.Build.props to the root solution directory with the following contents:
The intermediate files (and directories) will be created in the project directory and not in BaseIntermediateOutputPath ($(SolutionDir)build\intermediate\$(MSBuildProjectName)\), though the hirerarchy will match except for $(SolutionDir) (almost as if it's ignored/evaluated to "")
The dotnet publish command will later fail with Root assembly 'build\intermediate\<project-name>\<configuration>\<project-name>.dll' could not be found
Exceptions (if any)
Not exceptions, but errors during publishing (see build log below).
Further technical details
dotnet --info:
.NET SDK:
Version: 9.0.102
Commit: cb83cd4923
Workload version: 9.0.100-manifests.4a54b1a6
MSBuild version: 17.12.18+ed8c6aec5
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\9.0.102\
.NET workloads installed:
[wasm-tools]
Installation Source: VS 17.12.35707.178
Manifest Version: 9.0.1/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.workload.mono.toolchain.current\9.0.1\WorkloadManifest.json
Install Type: Msi
[android]
Installation Source: VS 17.12.35707.178
Manifest Version: 35.0.7/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.android\35.0.7\WorkloadManifest.json
Install Type: Msi
[ios]
Installation Source: VS 17.12.35707.178
Manifest Version: 18.1.9163/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.ios\18.1.9163\WorkloadManifest.json
Install Type: Msi
[maui-windows]
Installation Source: VS 17.12.35707.178
Manifest Version: 9.0.14/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maui\9.0.14\WorkloadManifest.json
Install Type: Msi
[maccatalyst]
Installation Source: VS 17.12.35707.178
Manifest Version: 18.1.9163/9.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\9.0.100\microsoft.net.sdk.maccatalyst\18.1.9163\WorkloadManifest.json
Install Type: Msi
Configured to use loose manifests when installing new manifests.
Host:
Version: 9.0.1
Architecture: x64
Commit: c8acea2262
.NET SDKs installed:
9.0.102 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.36 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
IDE: Visual Studio 2022 (17.12.4)
Build log with errors:
1>------ Build started: Project: <project-name>, Configuration: <configuration> x64 ------
1><project-name> -> <solution root>\build\staging\bin\<project-name>\<configuration>-x64\<project-name>.dll
1>ProjectDir: <solution root>\src\<project-name>\
1>BaseIntermediateOutputPath: <solution root>\build\intermediate\<project-name>\
1> Determining projects to restore...
1> Restored <solution root>\src\<project-name>\<project-name>.csproj (in 199 ms).
1> Optimizing assemblies for size. This process might take a while.
1>ILLink : error IL1032: Root assembly 'build\intermediate\<project-name>\<configuration>\<project-name>.dll' could not be found. [<solution root>\src\<project-name>\<project-name>.csproj]
1>E:\PackageCache\NuGet\microsoft.net.illink.tasks\8.0.12\build\Microsoft.NET.ILLink.targets(87,5): error NETSDK1144: Optimizing assemblies for size failed. [<solution root>\src\<project-name>\<project-name>.csproj]
1>
1>Workload updates are available. Run `dotnet workload list` for more information.
1><solution root>\src\Runtime\HostApp\Loader\<project-name>\<project-name>.csproj(37,3): error MSB3073: The command "dotnet publish <solution root>\src\<project-name>\<project-name>.csproj -r win-x64 -c Internal_LocalDev --disable-build-servers --no-build -o <solution root>\build\out\<project-name>\<configuration>-x64\win\" exited with code 1.
1>Done building project "<project-name>.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Intermediate files after dotnet restore ending up in project's directory instead of in BaseIntermediateOutputPath:
The text was updated successfully, but these errors were encountered:
Hello @MasterMann
I am unable to replicate the issue. My guess is it got picked by the MSBuild Issue you linked (dotnet/msbuild#2743). I tried reproducing using the 9.0.103 SDK
Can you confirm if the issue persists after updating? Thanks!
@edvilme to clarify, the issue ocurrs when doing a restore against a single project in a solution (either in the project SRC directory, or explicitly pointing to the .csproj).
The workaround for me, at least for now, is to explicitly set SolutionDir (/p:SolutionDir=<...>), though I'm planning to re-work my build workflow soon and use the Publish MSBuild task directly instead.
Oh sorry for the confusion @MasterMann
In that case it seems like the $(SolutionDir) variable is not present unless it is a solution being built, which makes sense as otherwise how would it know what to resolve to.
This is most likely an MSBuild issue, but I would suggest maybe using another MSBuild Property such as MSBuildStartupDirectory, passing the property directly, or building through a solution (.sln(x)) file.
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
"dotnet restore" and "dotnet publish" use relative
BaseIntermediateOutputPath
even if it's set to absolute path (or$(SolutionDir)
gets lost in the process somewhere).It's possible that
--artifacts-path
is ignored as well. I have tried setting it explicitly, as well as/p:ArtifactsPath
and<ArtifactsPath>...</ArtifactsPath>
inDirectory.Build.props
, but same result.To Reproduce
src/<project-name>/
)BaseIntermediateOutputPath
($(SolutionDir)build\intermediate\$(MSBuildProjectName)\
), though the hirerarchy will match except for$(SolutionDir)
(almost as if it's ignored/evaluated to "")dotnet publish
command will later fail withRoot assembly 'build\intermediate\<project-name>\<configuration>\<project-name>.dll' could not be found
Exceptions (if any)
Not exceptions, but errors during publishing (see build log below).
Further technical details
dotnet --info
:IDE: Visual Studio 2022 (17.12.4)
Build log with errors:
dotnet restore
ending up in project's directory instead of inBaseIntermediateOutputPath
:The text was updated successfully, but these errors were encountered: