dotnet / project-system

The .NET Project System for Visual Studio
MIT License
969 stars 387 forks source link

Cannot add audio resource to .NET Standard 2.0 project #3399

Open Petermarcu opened 6 years ago

Petermarcu commented 6 years ago

@chakrabar commented on Sat Jan 13 2018

I have an existing .NET Framework codebase, and I'm trying to port that to .NET Core. As part of the process, I'm converting my class libraries to .NET Standard 2.0 project.

In one of my projects, I'm using bunch of files as project resource (Resource.resx). When I add other files as Files, such as Excel.xlsx files, they work fine and I can simply use them in my code as

byte[] fileData = Resources.MyFileName;

But when I'm trying to add some Audio (.wav) file I'm facing the problem

  1. it is always getting added as Other.
  2. The project fails to compile with following error (see image below)

    System.IO.MemoryStream, netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 cannot be located.

This whole process works fine when I'm using in .NET Framework 4.6.1 project.

Note: I've also tried installing System.IO v4.3.0 NuGet package.

Further technical details

Class Library: .NET Standard 2.0 Operating system: Windows 8.1 x64 IDE: Visual Studio Community 2017 v15.5.2

netcore_resource_error


@Petermarcu commented on Sun Jan 14 2018

@livarcocc @davkean Do you think this is SDK or project system?


@livarcocc commented on Tue Jan 16 2018

@chakrabar Does a build of this project work from the command line?


@chakrabar commented on Wed Jan 17 2018

@livarcocc It worked! I built the project from cli and the project built fine without any errors!

dotnet build MyProject.csproj --no-incremental -f netstandard2.0 -r win81-x64 -v m

And strange enough, once it was built using cli, the resource appeared properly in VS as audio resource and it built in VS as well!! I could refer that resource in code like the other resources.

netcore_resource_error_solved


@livarcocc commented on Wed Jan 17 2018

@chakrabar glad it worked.

@Pilchie can you take a look? Seems to be failing only when trying to add it through VS.


@Petermarcu commented on Wed Jan 17 2018

Which repo is the best to track this in?


@Pilchie commented on Wed Jan 17 2018

dotnet/project-system.


@chakrabar commented on Mon Feb 05 2018

@Petermarcu is this being tracked anywhere?

ghuntley commented 6 years ago

Reproducible with Version 15.7.0 Preview 2.0; observations as follows:

.NET Framework

When dragging binary files onto the resx appdesigner:

Repro: dotnet-framework-class-library-compiles-file-is-copied-into-project-root.zip

netstandard20

When dragging binary files onto the resx appdesigner:

Repro: netstandard20-class-library-file-isnt-copied-uses-fragile-relative-path.zip

netcore

When dragging binary files onto the resx appdesigner:

Repro: dotnetcore-does-not-compile-file-isnt-copied-uses-fragile-relative-path.zip

verelpode commented 3 years ago

This issue seems to be fundamentally mostly the same issue as https://github.com/dotnet/project-system/issues/5460

Fundamentally the problem is that the RESX Designer/GUI needs to be modernized and updated for .csproj's that target NETFW 5, and made independent of the WinForms DLL. RESX is very useful but unfortunately the old dependency on WinForms is holding it back.