Cannot publish core console app + core app library tests
See original GitHub issueThe solution is here: https://github.com/orloffm/failingpublish
The first project is a netcoreapp2.0
exe
, the second is a test netcoreapp2.0
project for it. The solution dotnet build
s, but when I do
dotnet publish -c Release --self-contained -r win-x64
I get the following:
Microsoft (R) Build Engine version 15.5.179.9764 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 43.37 ms for C:\dev\failing_build\a\a.csproj.
Restore completed in 75.49 ms for C:\dev\failing_build\a.tests\a.tests.csproj.
C:\Program Files\dotnet\sdk\2.1.3\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.RuntimeIdentifierInference.targets(116,5): error : It is not supported to build or publish a self-contained application without specifying a RuntimeIdentifier. Please either specify a RuntimeIdentifier or set SelfContained to false. [C:\dev\failing_build\a\a.csproj]
a -> C:\dev\failing_build\a\bin\Release\netcoreapp2.0\win-x64\a.dll
a -> C:\dev\failing_build\a\bin\Release\netcoreapp2.0\win-x64\publish\
If I remove the test project from the solution, it works fine:
Microsoft (R) Build Engine version 15.5.179.9764 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
Restore completed in 43.62 ms for C:\dev\failing_build\a\a.csproj.
a -> C:\dev\failing_build\a\bin\Release\netcoreapp2.0\win-x64\a.dll
a -> C:\dev\failing_build\a\bin\Release\netcoreapp2.0\win-x64\publish\
I expect it to work, as this is almost a copy of a https://github.com/dotnet/docs/tree/master/samples/core/getting-started/unit-testing-using-dotnet-test, but with the main project switched to netcoreapp2.0
.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:13 (10 by maintainers)
Top Results From Across the Web
Self contained publication of .net core 2 console app not ...
Checking the publish folder, it would seem that the System.Data.SqlClient.dll assembly in there has a version of 4.6.25519.03. Anyone care to ...
Read more >Publish a .NET console application using Visual Studio
This tutorial shows how to publish a console app so that other users can run it. Publishing creates the set of files that...
Read more >Publish Self-contained problem - app still needs .netcore to ...
1, create a new Console App (.NET Core). Build it. Right-click on the project (ConsoleApp1) and select Publish Accept the default folder (bin\ ......
Read more >Unable to access reference project class library in console ...
I'm adding a using clause at the top of my app, and there is no option to reference. What am I missing?? This...
Read more >How YOU can get started with .NET Core and C# in VS Code
This article covers your first steps using .NET Core, the cross-platform version of .NET. We will be creating a solution, a library, a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@alexzaytsev-newsroomly @orloffm sry forgot to post the workaround half a year ago:
The workaround is to change the project reference to exclude the property:
At the moment, you may also get an “was restored using 2.1.1 but … 2.1.0 … used insead” error. To work around this one, add this to the referenced(!) project(s):
As suspected, the issue also occurs when an app references another app. selfcontainedrepro.zip also fails in the same way when the
testmainapp
is published withdotnet publish -r osx-x64 --self-contained
.This likely needs a change to MSBuild similar to https://github.com/Microsoft/msbuild/pull/1674 to remove the
SelfContained
global property for RID-agnostic P2Ps. (Or maybe for even for RID-specific ones?). cc @nguerrera @livarcocc