c# - How to use a resource file in Visual Studio 2015 -
i'm creating integration tests (web class library project) asp5 mvc6 application. want add resource file raw sql test project db preparation.
i wanted use old resources (.resx). it's not available in add new item project's menu.
i found this answer pointing github repo. guess reads file:
using (var stream = fileprovider.getfileinfo("compiler/resources/layout.html").createreadstream()) using (var streamreader = new streamreader(stream)) { return streamreader.readtoend().replace("~", $"{basepath}/compiler/resources"); } i tried using system.io.file.readalltext("compiler/resources/my.sql") in test helper project in testhelper class.
when used testhelper class in actual test project looking the file in test project directory.
testproject/compiler/resources/my.sql insetad of testhelperproject/compiler/resources/my.sql
i can figure out couple of workarounds. i'd right way. preferably in resx file:
string sql = resources.mysql; any suggestions?
edit
it little more complicated because there's no tooling support doable:
- create
resxfile or copy somewhere else classic c# project - if can use
sakebuild system, can use same target we, asp.net team use: https://github.com/aspnet/universe/blob/dev/build/_k-generate-resx.shade otherwise, need implement similar in own build scripts - place resources either
compiler/resources. if place them under other folder include them in project json (like here) - build using sake build using dnx. resource should available strong type object


Comments
Post a Comment