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.

dotnet publish won't embed edmx resources

See original GitHub issue

Steps to reproduce

  1. Create new ASP.NET Core Web Application (.NET Framework),
  2. Add new Project to solution (Visual C# > Windows Classic Desktop) and select Class Library (.NET Framework),
  3. Add EntityFramework 6.1.3 as a reference to previously added class library,
  4. Add new Item to class library (Visual C# Items > Data > ADO.NET Entity Data Model),
  5. Choose Model Contents -> EF Designer from database, select any of your database, also select that you want to use “Entity Framework 6.x”, and choose at least one table to include in your model, in this step VS will create EDMX file,
  6. Add reference to project “class library” from WebApplication,
  7. Build whole solution with Visual Studio, go to bin directory in Class Library folder, and open this library with any resource viewer (resedit, ILSpy), notice that few resources are embedded (*.msl, *.csdl, *.ssdl),
  8. Restore nuget packages “nuget restore Solution.sln” and publish solution with “dotnet publish Solution.sln”, go to bin directory in Class Library folder, and open this library with any resource viewer (resedit, ILSpy), notice that embedded resources are missing.

Expected behavior

“dotnet publish” and “MSBuild” should produce same libraries.

Actual behavior

Class library produced by “dotnet publish” is without embedded resources.

Environment data

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.3.9600 OS Platform: Windows RID: win81-x64 Base Path: C:\Program Files\dotnet\sdk\1.0.4

nuget output: NuGet Version: 4.1.0.2450

WebApplication1.zip

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:18 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
lamperskycommented, Sep 18, 2017

I have tried to compare what is the difference between “dotnet msbuild” and “msbuild” itself. Bacause Microsoft says that both commands have the exact same capabilities. https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-msbuild

dotnet msbuild

I was playing a bit with debugging “msbuild” regarding to this article: https://blogs.msdn.microsoft.com/visualstudio/2010/07/06/debugging-msbuild-script-with-visual-studio/.

I found that msbuild needs few additional files to run “EntityModelCodeGenerator” correctly. In msbuild instalation directory there are:

missing files

But I can’t find these two files in bundled (with dotnet SDK) version of msbuild. Maybe there are more missing files.

search results

1reaction
jonoliver82commented, Sep 15, 2017

@QuantumHive Obviously people will have different assembly names and would change it as required. I was merely building off the comment by @lampersky of using the (correct) output from msbuild that has the embedded resources, which in my build definition was already run before dotnet publish in order to build the solution and run the unit tests.

Read more comments on GitHub >

github_iconTop Results From Across the Web

dotnet publish won't embed edmx resources
Steps to reproduce. Create new ASP.NET Core Web Application (.NET Framework),; Add new Project to solution (Visual C# > Windows Classic Desktop) and...
Read more >
MetadataException: Unable to load the specified metadata ...
I had moved my EDMX file to another folder and had to change the build action to get the embedded resource names to...
Read more >
MSBuild reference for .NET SDK projects
This property is useful if you run dotnet publish on a solution file, as it allows automatic selection of projects that should be...
Read more >
Troubleshoot ASP.NET Core Localization
In this article. Localization configuration issues; Resource file naming issues; Missing resources; Resources & Class Libraries issues ...
Read more >
dotnet publish command - .NET CLI
Name. dotnet publish - Publishes the application and its dependencies to a folder for deployment to a hosting system.
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