Visual Studio 2015 .NETCore Class Class Library Library for bin / Debug / net452

I have a .NET Core class library project ClassLibrary1 created in Visual Studio 2015. In this class library project, I added the NewFolder folder that will be used by any project that references ClassLibrary1 .

So for example, I have a project called ConsoleApplication1 that references ClassLibrary1 . Every time I build ConsoleApplication1 , NewFolder should be copied

FROM

PROJECT_PATH\ClassLibrary1\bin\Debug\net452\win7-x64\NewFolder

FROM

PROJECT_PATH\ConsoleApplication1\bin\Debug\net452\win7-x64\NewFolder

UPDATE:

I added the following to the project.json file of my project ClassLibrary1 .

 "buildOptions: { "copyToOuput": "NewFolder" }" 

It only copies the PROJECT_PATH\ClassLibrary1\bin\Debug\net452\win7-x64\NewFolder PROJECT_PATH\ConsoleApplication1\bin\Debug\net452\win7-x64\NewFolder , but not to PROJECT_PATH\ConsoleApplication1\bin\Debug\net452\win7-x64\NewFolder when creating ConsoleApplication1 .

I have no idea how this should be done in .NET Core projects, because this does not look like behavior for projects other than .NET Core.

UPDATE 2:

In projects other than .NET Core, I simply add a script to the command line of events after the ClassLibrary1 build and automatically copy everything to ClassLibrary1/bin/Debug , including files and folders, to ConsoleApplication1/bin/Debug .

xcopy "$(ProjectDir)NewFolder" "$(TargetDir)NewFolder" /E /Y

+6
source share
1 answer

What I usually do in non-.NET Core creates a link to the folder / item in the project (your case is ConsoleApplication1 , and then sets it to copy.

this cannot be done in the .net kernel.

What you are doing is also wrong, project.json from ClassLibrary1 does not copy the files to the output of ConsoleApplication1 , what you have to do is add the following to project.json ConsoleApplication1

 "copyToOutput": { "mappings": { "NewFolder/": { "include": "../ClassLibrary1/bin/Debug/net452/win7-x64/NewFolder/**" } } } 

mappings - defines folders for copying ( NewFolder ) (required / )

include - Defines the glob patterns and file paths that must be included for copying to create output.

UPDATE

you can embed your files using buildOptions and access it using

 var assembly = Assembly.GetExecutingAssembly(); var resourceName = "MyCompany.MyProduct.MyFile.txt"; using (Stream stream = assembly.GetManifestResourceStream(resourceName)) using (StreamReader reader = new StreamReader(stream)) { string result = reader.ReadToEnd(); } 
+1
source

Source: https://habr.com/ru/post/1011537/


All Articles