I'm creating a second issue because the first one dotnet/sdk#8334 has been closed without a solution and has not been reopened.
Create a new solution using:
dotnet new sln --name TestSolution
Create and Add a class library project:
dotnet new classlib --name TestProject --output TestProject
dotnet sln add ./TestProject/TestProject.csproj
In TestProject.csproj change the TargetFramework property to net46
Restore and build the project using:
dotnet restore
dotnet build
The project should build successfully.
The project fails to build with the following error message:
E:\Program Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [E:\Work\TestSolution\TestProject\TestProject.csproj]
However, when using msbuild directly the build passes.
Furthermore, the solution builds with the following:
dotnet msbuild -p:FrameworkPathOverride="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6"
dotnet --info output:
.NET Command Line Tools (1.0.4)
Product Information:
Version: 1.0.4
Commit SHA-1 hash: af1e6684fd
Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Base Path: E:\Program Files\dotnet\sdk\1.0.4
+1
I also have the very same issue.
I set up a new build machine (Windows Server 2012 R2 Standard).
I installed the .net core 1.0.4 SDK on it.
I also installed the Visual Studio 2017 Build tools as well as the .NET 4.6, 4.6.1 and 4.6.2 targeting packs.
The solution that fails to build one project is here:
https://github.com/canonn-science/CanonnApi/tree/add-galmap/CanonnApi.Backend
The web api project builds correctly, but the Database.Autupdater project fails.
Environment data
C:\>dotnet --info
.NET Command Line Tools (1.0.4)
Product Information:
Version: 1.0.4
Commit SHA-1 hash: af1e6684fd
Runtime Environment:
OS Name: Windows
OS Version: 6.3.9600
OS Platform: Windows
RID: win81-x64
Base Path: C:\Program Files\dotnet\sdk\1.0.4
C:\>
The part of the build log that marks the error:
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Microsoft.Common.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.6" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend. [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: The "GenerateRuntimeConfigurationFiles" task failed unexpectedly. [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\bin\Release\net46\win8-x64\Canonn.Database.AutoUpdater.runtimeconfig.json'. [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: at System.IO.Win32FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent) [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: at System.IO.Win32FileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent) [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: at Microsoft.NET.Build.Tasks.GenerateRuntimeConfigurationFiles.WriteToJsonFile(String fileName, Object value) [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: at Microsoft.NET.Build.Tasks.GenerateRuntimeConfigurationFiles.WriteRuntimeConfig(ProjectContext projectContext) [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: at Microsoft.NET.Build.Tasks.GenerateRuntimeConfigurationFiles.ExecuteCore() [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
[11:26:30][Step 1/2] C:\Program Files\dotnet\sdk\1.0.4\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.targets(129,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() [C:\TeamCity\buildAgent\work\28d7fb7b286cbaf\CanonnApi.Database.AutoUpdater\Canonn.Database.AutoUpdater.csproj]
+1
+1
This seems to be working on the latest 2.0.0 CLI on Windows. Closing for now. Please comment or re-activate if this still reproes using the 2.0.0 CLI.
@livarcocc The problem still persists on the latest CLI. Please could you reopen this issue.
The error indicates that the targeting packs for the targeted .net framework version aren't installed. You can get them from https://www.microsoft.com/net/targeting or via the "Individual Compontens" tab of the Visual Studio Installer when installing/modifying VS
You can check if a directory with the appropriate version is available in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework
I have the appropriate targeting pack installed. I can build the solution by manually specifying the FrameworkPathOverride parameter which points at the C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6 directory.
@dasMulli This issue has not been fixed, please reopen.
@mpforce1 I don't have permissions for that, you should have..
Does the same project build using the msbuild from the VS 2017 developer command prompt?
What now catches my eye is the E: program files path path and the C: x86 program files path, so it may be interesting which environment variables influence msbuild's lookup. Could yo do a dotnet msbuild /bl and upload the resulting msbuild.binlog file?
@dasMulli Oh sorry, I didn't realise you wouldn't have permissions. I don't seem to either so I'm not sure what's wrong.
I don't use VS, I've been using Jetbrains Rider. I'm not sure about the VS 2017 developer command prompt.
msbuild.binlog.log
I wasn't sure how people normally upload binlog files so I added a log extension. Hopefully that's ok. Thanks.
So msbuild expects the reference assemblies to be installed into whatever the 32bit program files is.
Your ProgramFiles(x86) environment variable points to E:\Program Files (x86), but the reference assemblies are on your C: drive.. Probably installed before you changed this setting?
You could try reinstalling them, making a link or just copying them over..
Reinstalling the targeting pack doesn't seem to change anything. Interestingly, uninstalling it doesn't even seem to remove the assemblies from the C drive. Is there maybe a bug in the targeting pack installer? Is there a registry entry that shows where windows thinks the assemblies are installed?
I re-activated, but @dasMulli is right. I am not sure what else we could do here.
Copying the reference assemblies over to the E drive makes the build work. I'm not exactly happy with this solution but I'm convinced that this isn't a dotnet cli issue. Thanks for helping me.
Another workaround would be to set the ReferenceAssemblyRoot environment variable to the full path to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework on your system.
I had to do this override as well even after installing all the targeting packs. I set the environment variable as well and that did nothing. I set it in my system variables, so maybe I needed to set it at runtime?
I generated the binlog and all of my environment variables were correct.
For me the only thing that worker (after installing all the targeting packs) was to repair the .NET Core SDK installation.
@labmorales This also worked for me!
project i have executed from github: https://github.com/radhegithub/KuberneteVS2019.git
DONET VS 2019 docker , When building the container, @Linux machine, its throwing error, this does not work at window 2019 server as well where in i have installed vs2019,docker,kbectl etc
Please could help me since i am unable to find resultion from last 3 days, do not how to proceed.
It would be great kind if someone could help me
jenkinlinux@jenkins:~/KuberneteVS2019$ docker build myfirstaks
Sending build context to Docker daemon 5.549MB
Step 1/16 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1 AS base
---> 0661f995e7db
Step 2/16 : WORKDIR /app
---> Using cache
---> 39c6c1878227
Step 3/16 : EXPOSE 80
---> Using cache
---> 0bc03839e6d7
Step 4/16 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build
---> 3edbb65c61da
Step 5/16 : WORKDIR /src
---> Using cache
---> 5532a164cc6c
Step 6/16 : COPY ["./myfirstaks.csproj", "myfirstaks/"]
---> Using cache
---> 1b805749238c
Step 7/16 : RUN dotnet restore "myfirstaks/myfirstaks.csproj"
---> Using cache
---> f98d70a923b0
Step 8/16 : COPY . .
---> Using cache
---> ab3d5ef3aab0
Step 9/16 : WORKDIR "/src/myfirstaks"
---> Using cache
---> 6608037bdf2c
Step 10/16 : RUN dotnet build "myfirstaks.csproj" -c Release -o /app/build
---> Running in 0ecf62ae3e4f
Microsoft (R) Build Engine version 16.5.0+d4cbfca49 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 45.89 ms for /src/myfirstaks/myfirstaks.csproj.
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/src/myfirstaks/myfirstaks.csproj]
Build FAILED.
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/src/myfirstaks/myfirstaks.csproj]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:02.23
The command '/bin/sh -c dotnet build "myfirstaks.csproj" -c Release -o /app/build' returned a non-zero code: 1
jenkinlinux@jenkins:~/KuberneteVS2019$
Got fixed by Modifying directory paths:Its Docker engine issue which is not parsing correctly
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["aspnetcorelinuxdemo.csproj", "./"]
RUN dotnet restore "aspnetcorelinuxdemo.csproj"
COPY . ./aspnetcorelinuxdemo
WORKDIR "/src/aspnetcorelinuxdemo"
RUN dotnet build "aspnetcorelinuxdemo.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "aspnetcorelinuxdemo.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "aspnetcorelinuxdemo.dll"]
Most helpful comment
+1
I also have the very same issue.
I set up a new build machine (Windows Server 2012 R2 Standard).
I installed the .net core 1.0.4 SDK on it.
I also installed the Visual Studio 2017 Build tools as well as the .NET 4.6, 4.6.1 and 4.6.2 targeting packs.
The solution that fails to build one project is here:
https://github.com/canonn-science/CanonnApi/tree/add-galmap/CanonnApi.Backend
The web api project builds correctly, but the Database.Autupdater project fails.
Environment data
The part of the build log that marks the error: