question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent target path between solution build and project build when platform specified

See original GitHub issue

Steps to reproduce

The target path / output directory are different building the solution vs building the project when the platform is specified. dotnet build MyProject.sln /p:Platform="Any CPU"
dotnet build MyProject.csproj /p:Platform="Any CPU"
(where MyProject.sln contains MyProject.csproj)

Expected behavior

The TargetPath for MyProject for both commands should be the same.

Actual behavior

TargetPath when building the solution: MyProject\bin\Debug\netstandard2.0\MyProject.dll TargetPath when building the project: MyProject\bin\Any CPU\Debug\netstandard2.0\MyProject.dll

Environment data

My environment data
.NET Core SDK (reflecting any global.json):
 Version:   2.2.101
 Commit:    236713b0b7

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.2.101\

Host (useful for support):
  Version: 2.2.0
  Commit:  1249f08fed

.NET Core SDKs installed:
  1.0.0-preview2-003131 [C:\Program Files\dotnet\sdk]
  1.0.0-preview4-004233 [C:\Program Files\dotnet\sdk]
  1.0.0-rc3-004530 [C:\Program Files\dotnet\sdk]
  1.0.0 [C:\Program Files\dotnet\sdk]
  1.0.4 [C:\Program Files\dotnet\sdk]
  1.1.0 [C:\Program Files\dotnet\sdk]
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.502 [C:\Program Files\dotnet\sdk]
  2.1.503 [C:\Program Files\dotnet\sdk]
  2.1.504 [C:\Program Files\dotnet\sdk]
  2.1.505 [C:\Program Files\dotnet\sdk]
  2.2.101 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download```
</details>

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
rainersigwaldcommented, Apr 2, 2019

The solution -> individual project MSBuild call uses the solution configuration map to explicitly specify Configuration and Platform for the project. The individual project build does not, so any specified Platform would be used verbatim.

That behavior makes it sound like there’s an x64 solution configuration but it points to the AnyCPU configuration in individual projects. @tylerohlsen can you share the .sln file? When I created a new one I got this exact behavior:

S:\repro\dotnet\cli\issues\11051>dotnet new xunit && dotnet new sln && dotnet sln add .
The template "xUnit Test Project" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on S:\repro\dotnet\cli\issues\11051\11051.csproj...
  Persisting no-op dg to S:\repro\dotnet\cli\issues\11051\obj\11051.csproj.nuget.dgspec.json
  Restore completed in 478.53 ms for S:\repro\dotnet\cli\issues\11051\11051.csproj.

Restore succeeded.

The template "Solution File" was created successfully.
Project `11051.csproj` added to the solution.

S:\repro\dotnet\cli\issues\11051>set PLATFORM=x64

S:\repro\dotnet\cli\issues\11051>dotnet build 11051.sln
Microsoft (R) Build Engine version 16.0.443+g5775d0d6bb for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Persisting no-op dg to S:\repro\dotnet\cli\issues\11051\obj\11051.csproj.nuget.dgspec.json
  Restore completed in 35.35 ms for S:\repro\dotnet\cli\issues\11051\11051.csproj.
C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [S:\repro\dotnet\cli\issues\11051\11051.csproj] 
  11051 -> S:\repro\dotnet\cli\issues\11051\bin\Debug\netcoreapp3.0\11051.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.63

S:\repro\dotnet\cli\issues\11051>dotnet test 11051.csproj --no-build
Test run for S:\repro\dotnet\cli\issues\11051\bin\x64\Debug\netcoreapp3.0\11051.dll(.NETCoreApp,Version=v3.0)
Microsoft (R) Test Execution Command Line Tool Version 16.0.0-preview-20190124-02
Copyright (c) Microsoft Corporation.  All rights reserved.

The test source file "S:\repro\dotnet\cli\issues\11051\bin\x64\Debug\netcoreapp3.0\11051.dll" provided was not found.

That defaulted to this solution configuration mapping:

image

I used the VS configuration manager to add a project platform and reference it from the x64 solution platform configuration:

diff --git a/11051.csproj b/11051.csproj
index a732202..3185fb8 100644
--- a/11051.csproj
+++ b/11051.csproj
@@ -1,10 +1,12 @@
-<Project Sdk="Microsoft.NET.Sdk">
+<Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
     <TargetFramework>netcoreapp3.0</TargetFramework>
     <RootNamespace>_11051</RootNamespace>
 
     <IsPackable>false</IsPackable>
+
+    <Platforms>AnyCPU;x64</Platforms>
   </PropertyGroup>
 
   <ItemGroup>
diff --git a/11051.sln b/11051.sln
index c25320c..aee2053 100644
--- a/11051.sln
+++ b/11051.sln
@@ -1,9 +1,9 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26124.0
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.28801.201
 MinimumVisualStudioVersion = 15.0.26124.0
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "11051", "11051.csproj", "{C5BBC588-CCB0-485E-9169-E076EF6BFE3A}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "11051", "11051.csproj", "{C5BBC588-CCB0-485E-9169-E076EF6BFE3A}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -20,8 +20,8 @@ Global
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
 		{C5BBC588-CCB0-485E-9169-E076EF6BFE3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{C5BBC588-CCB0-485E-9169-E076EF6BFE3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{C5BBC588-CCB0-485E-9169-E076EF6BFE3A}.Debug|x64.ActiveCfg = Debug|Any CPU
-		{C5BBC588-CCB0-485E-9169-E076EF6BFE3A}.Debug|x64.Build.0 = Debug|Any CPU
+		{C5BBC588-CCB0-485E-9169-E076EF6BFE3A}.Debug|x64.ActiveCfg = Debug|x64
+		{C5BBC588-CCB0-485E-9169-E076EF6BFE3A}.Debug|x64.Build.0 = Debug|x64
 		{C5BBC588-CCB0-485E-9169-E076EF6BFE3A}.Debug|x86.ActiveCfg = Debug|Any CPU
 		{C5BBC588-CCB0-485E-9169-E076EF6BFE3A}.Debug|x86.Build.0 = Debug|Any CPU
 		{C5BBC588-CCB0-485E-9169-E076EF6BFE3A}.Release|Any CPU.ActiveCfg = Release|Any CPU

At this point, everything worked:

S:\repro\dotnet\cli\issues\11051>dotnet build 11051.sln
Microsoft (R) Build Engine version 16.0.443+g5775d0d6bb for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Persisting no-op dg to S:\repro\dotnet\cli\issues\11051\obj\11051.csproj.nuget.dgspec.json
  Restore completed in 39.96 ms for S:\repro\dotnet\cli\issues\11051\11051.csproj.
C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [S:\repro\dotnet\cli\issues\11051\11051.csproj] 
  11051 -> S:\repro\dotnet\cli\issues\11051\bin\x64\Debug\netcoreapp3.0\11051.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.34

S:\repro\dotnet\cli\issues\11051>dotnet test 11051.csproj --no-build
Test run for S:\repro\dotnet\cli\issues\11051\bin\x64\Debug\netcoreapp3.0\11051.dll(.NETCoreApp,Version=v3.0)
Microsoft (R) Test Execution Command Line Tool Version 16.0.0-preview-20190124-02
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 4.3017 Seconds
0reactions
dashesycommented, Dec 12, 2019

This is very confusing. Also related to this issue:

There was already a <platforms>x64</platforms> that when I build in VS2019 is used to put binaries in bin/x64/Debug/netcoreapp2.2 but dotnet run needed <platform>x64</platform>. Otherwise dotnet run would instead use bin/Debug/netcoreapp2.2

VS2019 works fine with <platforms>, but dotnet only respects <platform> even if <platforms> has a single entry.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solution-level `--output` option no longer valid for build- ...
When a solution is built with the --output option, the OutputPath property is set to the same value for all projects, which means...
Read more >
Build specific Visual studio project under project solution ...
Here is my project structure Poject.sln ProjectA porjectB projectC Libraries libA libB msbuild "project.sln" target:"D:\Projects\Source\Demo\ ...
Read more >
Inconsistent ordering of MSBuild properties added by cpp
I generally set a project's intermediate folder to C:\projects\intermediate\$(TargetName)\ and TargetName to $(ProjectName)_$(Configuration)_$( ...
Read more >
Troubleshooting AWS CodeBuild
Issue: When you try to run a build project, the build fails with this error. Possible cause: Your source repository has a self-signed...
Read more >
error NETSDK1194: The "--output" option isn't supported ...
The --output option is disallowed because all outputs of all built projects would be copied into the specified directory, which isn't compatible ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found