dotnet build solutionWithWindowsService.sln
Solution builds successfully
C:\Program Files\dotnet\sdk\2.1.4\Microsoft.Common.CurrentVersion.targets(2979,5): error MSB4216: Could not run the "GenerateResource" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x86". Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "C:\Program Files\dotnet\sdk\2.1.4\MSBuild.exe" exists and can be run. [D:\git\DemoWindowsService.csproj]
0 Warning(s)
$ dotnet --info
.NET Command Line Tools (2.1.4)
Product Information:
Version: 2.1.4
Commit SHA-1 hash: 5e8add2190
Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.4\
Microsoft .NET Core Shared Framework Host
Version : 2.0.5
Build : 17373eb129b3b05aa18ece963f8795d65ef8ea54
This is expected. The dotnet CLI supports a subset of the projects currently supported by full desktop msbuild.
We know of this limitation but don't have short term plans to address it at the moment.
In this case, I would recommend using msbuild.exe to build your solution.
Let us know if msbuild does not work for you and we can re-activate this issue.
While it may not fix all problems when building with the CLI, you could try adding this to the csproj to fix this specific problem:
<PropertyGroup Condition="'$(MSBuildRuntimeType)' == 'Core' Or '$(TargetFrameworkIdentifier)' != '.NETFramework'">
<GenerateResourceMSBuildArchitecture Condition=" '$(GenerateResourceMSBuildArchitecture)' == '' ">CurrentArchitecture</GenerateResourceMSBuildArchitecture>
<GenerateResourceMSBuildRuntime Condition=" '$(GenerateResourceMSBuildRuntime)' == '' ">CurrentRuntime</GenerateResourceMSBuildRuntime>
</PropertyGroup>
A better solution would be to create a new .NET Core Console applictation, then edit the csproj file to change netcoreapp2.0
to e.g. net461
to get a project file format that is supported by the CLI, though has a fewer support for existing technologies.
@dasMulli Adding that PropertyGroup to the csproj did fix it! Thanks!
Once again, another dotnet issue resolved by ordinary GitHub users and not the devs!
P.S. Dev's recommended solution crashes with "msbuild command not recognized."
"msbuild command not recognized."
Did you get the same MSB4216 error from before? That does not seem related.
Most helpful comment
While it may not fix all problems when building with the CLI, you could try adding this to the csproj to fix this specific problem:
A better solution would be to create a new .NET Core Console applictation, then edit the csproj file to change
netcoreapp2.0
to e.g.net461
to get a project file format that is supported by the CLI, though has a fewer support for existing technologies.