-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET Core 2.0 Console App and publish by SCD (win10-x64) will fail #1039
Comments
Does this only happen if you set the RuntimeIdentifiers? If you remove that property, does VS build successfully? It seems like VS is looking for the dll in the wrong output folder: it should look under bin and not obj. Does it work if you run msbuild.exe ConsoleApp3.csproj? If that fails as well, could you run msbuild.exe ConsoleApp3.csproj /bl:log.binlog and then share the binlog file with us? |
|
@Pilchie given that this works in VS and the command line, can you have someone take a look at it from the ProjectSystem point of view. Also noted that I tried on the latest 15.5 bits and I can't repro it. |
I just install VS 2017 Preview and re-create a new project, then publish by RuntimeIdentifiers of win10-x64. This progress also is failed. But the dialog of publish failed show a log file and I have put as following 2017/10/21 10:41:39 =================== |
Can you try win-x64 instead of win10-x64? |
I have changed to <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
</PropertyGroup>
</Project> but it also got following error log on my VS2017 15.5 preview.
|
And it does still work from the command line with |
Yes, it work fine and all files for SCD have been generated.
|
@Petermarcu Does VS2017 invoke |
Just encountered this issue. |
@BillHiebert is this yours? |
@BillHiebert is probably the closest person to be able to describe what VS publish does internally. I'm not sure that it calls out to dotnet.exe. |
@vijayrkn - can you respond? |
I think It is failing from VS because the runtimeIdentifier to use during publish is not specified. You are specifying it for the commandline scenario when you pass this flag (-r win-x64) but this is not specified in the VS publish scenario. Solution: |
I have changed RuntimeIdentifiers to RuntimeIdentifier in the csproj and can publish from VS successfully. <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</Project> If I use multiple RIDs, like this : win-x64;osx-x64;rhel-x64 in the csproj and republish any one of RIDs. The project of Visual Studio will become unavailable. <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RuntimeIdentifier>win-x64;osx.10.11-x64;rhel-x64</RuntimeIdentifier>
</PropertyGroup>
</Project> But in this web page Self-contained deployment without third-party dependencies, the My question is that how can I use multiple RIDs in the csproj and can publish from VS? |
if you want to specify multiple RIDs in the csproj, then you need to set RuntimeIdentifiers instead of RuntimeIdentifier in the csproj (In the above screenshot you are missing the trailing 's' ).
Once this is set, you can restore the project and go to the publish setting page and pick the RID that you need to publish with (and click save). Then you will be able to publish for that specific RID. |
When I set |
@vulcanlee Thank you for reporting this issue. We can reproduce the issue on our side with the latest released bits. We will investigate the root cause and get back. /cc @mlorbetske |
@vijayrkn do you still need this open here? Is the issue understood and is there any more that can be shared? |
Just followed up internally. This is the same issue as: https://developercommunity.visualstudio.com/content/problem/101502/vs2017-153-net-core-20-publish-a-self-contained-ap.html They are planning on fixing this in the release of Visual Studio 2017 v15.5. |
This issue is still present in the latest stable VS release. |
You can use CLI to publish SCD |
@felschr - The fix for this issue will be available in the next upcoming release. Until then the work-around will be to add the following to the csproj |
It is 2018, we already had at least two update to version 15.5 and this error still happens! |
Assets file 'C:\obj\project.assets.json' doesn't have a target for '.NETCoreApp,Version=v2.0/win-x64' |
@vijayrkn any updates on which release the fix is supposed to be in? |
The fix is available in the current VS preview - https://www.visualstudio.com/thank-you-downloading-visual-studio/?ch=pre&sku=Enterprise&rel=15 |
Still have the problem on build 15.5.4 |
@vijayrkn Hey you're right - sorry about that. I did update, but the issue still seems to be there, ended up just using |
@vijayrkn So, did you check my project ? Can you confirm, that issue is really there ? |
@gitchomik - Sorry for the late response. I thought I replied to this thread but apparently didn’t. The issue you are running into is that the RID is not flowing to the dependenct projects. If you specify the RuntimeIdentifier in ClassLibraryA, then publish should work fine. This issue is not Publish specific, If you clean all the projects. add a single RID to the Console App and build, you will notice that the ClassLibraryA is not built for the RID specified in ConsoleApp. Publish fails because publish doesnt find the RID specific artifacts for ClassLibraryA @Pilchie - Is this something tracked by the .NET Project system - To pass the RID to all the dependent projects during build? |
@vijayrkn Sorry doesn't works for me. When all project has the same RuntimeIdentifier (not RuntimeIdentifierS) it works. When dependent projects doesn't contains RuntimeIdentifiers at all, then publish works but dependent projects aren't RID specific. I don't understand how should I prepare .csproj to work with multiply RIDs (especially that it is work fine when using command "dotnet publish"). I just want to prepare .csproj to work with multiply RIDs, and switch them when publishing. How can I managed it ? |
@vijayrkn - there is nothing tracking this on the project system side. Also tagging @dsplaisted here. |
@vijayrkn Does this fail when you run |
@dsplaisted - Running @gitchomik - I looked at your repro project again and if you remove this line from classlibrary, then publish should work fine. When the RuntimeIdentifiers is specified in the dependent project, the dotnet project system is looking for the dlls in the RID specific folder for some reason. |
@vijayrkn It sounds like this should be filed as a separate bug, possibly in dotnet/project-system. |
@vijayrkn - Yes, it is true, dependent projects without RuntimeIdentifiers works fine (as I said before). But, I thought that publishing using RID = debian.8-x64, also build and publish dependent projects using same RID = debian.8-x64. So, isn't project system should looking for the dlls in the RID specific folder ? |
Has anyone managed to solve it? |
@afernandes This issue is fixed in VS 15.7. Can you please update to the latest version and try? |
vijayrkn: sorry, version 15.7 still doesn't work for me. |
@gitchomik - What issues are you running into? With 15.7, Publish supports both SCD (Self-Contained) & FDD (Framework dependent) deployments with RIDs. It is not required to add RIDs to the csproj any more. Publish will do a restore and publish. I took your repro project (https://github.com/gitchomik/dotnet_core_issues_1039) removed all the RIDS from all the csproj. From the Publish dialog, selected SCD with RID & published and everything worked as expected.
If you have multiple RIDs in the depdent project, then you may run into this issue but you dont need to add RIDs to the csproj any more. |
@vijayrkn I recorded a full steps video for you. It really doesn't work. Here is the full video demostrate the whole reproduce steps: Here is the log:
|
vijayrkn: VS.NET now doesn't support RIDs ? (why ? I don't get it) |
my project is based on the project "SimplCommerce" today I did not have time, but tomorrow I put the project in github I'm using windows 7. error: tomorrow I will do more tests and I will inform |
@doggy8088 - can you please share the output log? @gitchomik - What I meant is - you are not required to add RIDs to the csproj if they are using it only during publishing (Adding the RIDs in csproj is still supported). If you want to add additional RIDs, you can add them to the publish profile as well under - |
@vijayrkn I already shared. Don't you see? |
@doggy8088 - I saw the video and the stack above. Can you also please share the build output log? It should have information on the restore and build during publish. |
@vijayrkn here you are:
I also tried to add a
The output log is:
|
Output windows
log (tmp)
I'm also sending the code to github |
Project 1: WebHost.csproj <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Content Remove="wwwroot\modules\core\Logo_Semp.png" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="4.2.2" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.8" />
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.2" />
<PackageReference Include="Serilog.Settings.Configuration" Version="2.6.1" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Modules\Semp.Module.Cms\Semp.Module.Cms.csproj" />
<ProjectReference Include="..\Modules\Semp.Module.Core\Semp.Module.Core.csproj" />
<ProjectReference Include="..\Modules\Semp.Module.Localization\Semp.Module.Localization.csproj" />
<ProjectReference Include="..\Semp.Infrastructure\Semp.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Modules\" />
<Folder Include="wwwroot\user-content\" />
</ItemGroup>
<ItemGroup>
<None Include="wwwroot\modules\core\Logo_Semp.png" />
</ItemGroup>
</Project>
Project 2: Module.Core.csproj <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<PreserveCompilationContext>false</PreserveCompilationContext>
<EnableDefaultContentItems>false</EnableDefaultContentItems>
<OutputType>Library</OutputType>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\Semp.Infrastructure\Semp.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="2.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.0.2" />
<PackageReference Include="System.Data.SqlClient" Version="4.4.3" />
</ItemGroup>
</Project>
|
Project on GitHub |
I finally succeeded, but only with SelfContained marked as false and removing the RuntimeIdentifier tag. |
however, marking the SelfContained as true I have to select the RuntimeIdentifier again to happen the same error. |
@doggy8088 - Thank you for sharing the log. From the log, it looks like you have an older version of CLI. With the new CLI, the restore should happen to |
@afernandes - I tried your repro project (https://github.com/afernandes/Projeto-Piloto). If you add the following RuntimeIdentifier to all the dependent projects, then it should work fine.
|
Issue Title
I use Visual Studio 2017 (15.4.1) and just create a .NET Core 2.0 Console Project, then publish by RuntimeIdentifiers of win10-x64 and show dialog for "Publish failed" and will get "Could not copy the file "obj\Release\netcoreapp2.0\win10-x64\ConsoleApp3.dll" because it was not found" error message.
This result will cause me to fail to produce SCD files.
But if I publish above SCD by CLI :
dotnet publish -c Release -r win10-x64
, it work fine and no problem.General
My environment is Windows 10 Build 1607 or 1709, and Visual Studio 2017 Enterprise 15.4.1.
The content of .csproj is
Following is my console app sample code
You can see my all operation on this video.
Following is build output log:
The text was updated successfully, but these errors were encountered: