我只想转向基于代码的流畅的映射,但这个问题并不是我的一个NHibernate映射文件所独有的.通过在解决方案资源管理器中右键单击的项目项目的旧属性页就可以了.我希望如果这样一个嵌入式资源的东西依然存在,那么就像project.Json那样,我们必须指定这个.
解决方法 UPDATE我以前的答案不再有效(自RC2起),资源现在被标记为已弃用. (谢谢@Yossarian)
现在正确的方法是使用buildOptions / embed:
..."buildOptions": { "emitEntryPoint": true,"embed": [ "9NliZmx.png" ]},...
您必须使用project.Json中的部分资源,就像这样
{ "compile": "*.cs","resource": [ "mapPing.xml" ]}
By default all code files in a directory containing a project.Json are included in the project. You can control this with the include/exclude sections of the project.Json.
Most sections of the project.Json file that deal with files allow glob patterns,which are often called wildcards.
包含/排除属性列表
name default value===============================================compile compileExclude content **/* contentExclude preprocess compiler/preprocess/**/*.cs preprocessExclude resource compiler/preprocess/resources/**/* resourceExclude shared compiler/shared/**/*.cs sharedExclude publishExclude bin/**;obj/**;**/.*/** exclude
更多信息:http://docs.asp.net/en/latest/dnx/projects.html#including-excluding-files
您可以看到以下示例:
Program.cs中
using System;using System.Reflection;namespace ConsoleApp1{ public class Program { public static voID Main(string[] args) { var assemblyname = new Assemblyname("ConsoleApp1"); var resources = string.Join(Environment.Newline,Assembly.Load(assemblyname).GetManifestResourcenames()); Console.Writeline("List of Manifest Resource names"); Console.Writeline("======================"); Console.Writeline(resources); } }}
project.Json
{ "version": "1.0.0-*","description": "ConsoleApp1 Console Application","authors": [ "Alberto Monteiro" ],"Tags": [ "" ],"projectUrl": "","licenseUrl": "","compilationoptions": { "emitEntryPoint": true },"resource": "9NliZmx.png","dependencIEs": { },"commands": { "ConsoleApp1": "ConsoleApp1" },"frameworks": { "dnx451": { },"dnxcore50": { "dependencIEs": { "Microsoft.CSharp": "4.0.1-beta-23516","System.Collections": "4.0.11-beta-23516","System.Console": "4.0.0-beta-23516","System.linq": "4.0.1-beta-23516","System.Threading": "4.0.11-beta-23516","System.IO": "4.0.11-beta-23516","System.IO.fileSystem": "4.0.1-beta-23225","System.Reflection": "4.1.0-beta-23516" } } }}
产量
List of Manifest Resource names======================ConsoleApp1.9NliZmx.png总结
以上是内存溢出为你收集整理的c# – 如何使XML文件成为vNext(ASP.NET 5)类库中的嵌入式资源?全部内容,希望文章能够帮你解决c# – 如何使XML文件成为vNext(ASP.NET 5)类库中的嵌入式资源?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)