-
Notifications
You must be signed in to change notification settings - Fork 257
//css_resource fails to resolve relative paths #107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Yes this is a problem. Though in your sample there are some other inconsistencies that prevent it from working. The fix instructions below is also a work around for you until the release is out: In 'Script.cs' replace //css_resource ..\Properties\Resources.resx, ..\Properties\Resources.resources; with //css_resource ..\MyForms\FormWithResources.resx, ..\MyForms\FormWithResources.resources; Remove You can also omit 'FormWithResources.resources;' part. It is optional: //css_resource ..\MyForms\FormWithResources.resx |
Thanks for quick evaluation and fix! Also thanks for the hint on the optional second part of the Regarding the inconsistencies: The attached reduced project may not require Also, my project requires that the compiled resource file name explicitly contains the Otherwise a runtime error will be thrown:
The message says something like "Could not find resources for the given or neutral culture. Ensure that Seems as if the Visual Studio Designer has some additional requirements or constraints regarding the resource file names. |
Yes it does. |
I have also updated the documentation with the |
* CS-Script.Core - Issue #106: Fix netstandard2 version to work in 4.6.1 and fix ReferenceDomainAssemblies - Fix netstandard2 version to work in 4.6.1 and fix ReferenceDomainAssemblies * CS-Script - Issue #108: Option to no longer suppress TargetInvocationException in AsmBrowser - Fixed problem with `cscs -config:get` not handling the properties containing '_' - Issue #107: //css_resource fails to resolve relative paths - Solved problem with `MarshalByRefObjectWithInfiniteLifetime` being defined in both cscs and CSScriptLibrary - Renamed MarshalByRefObjectWithInfiniteLifetime -> CSScriptLibrary.MarshalByRefObjectWithInfiniteLifetime - Processing feedback on #98 fixes.
I confirm that the previously supplied sample now works. But in my environment I have one more indirection (once more related to NUnit testing), and I still get an error indicating that something is wrong with handling indirections:
...if I specify...
...and...
...if I specify...
...i.e. without preceeding Problem: I have tried to reproduce this issue with this modified sample that has an additional indirection: However, the error I get now is different:
When executing this script from my hosting application, everything works fine. So, there must still be something wrong in handling the current directory or the directory path of an indirected scriptlet. Again, no need to hurry, it's just some of my NUnit generated test cases that throw an exception (due to the additional indirection). Running the scripts manually works fine (one indirection less). |
I guess that in this case if you have One of the things that I really disliked about MSTest and NUnit (though in less degree) is that they always insist on performing the test outside of the project file structure. I appreciate their motivation, but the file structure may also be a reflection of the production runtime conditions. May be if you force NUnit to perform the test ion the solution location instead of the temp dirs the problem will be solved. |
I fully agree that the file structure matters, actually I consider it the only truth. That's also the reason why I insisted on proper resolution of relative paths, and that relative paths should be considered relative to the file where the path is stated. I will debug the NUnit case at a later moment. (As mentioned, I can live with the issue for the moment.) But I ask you to also take a look at the modified sample, since that issue is not related to NUnit. I think it's something not 100% proper in CSScript relative path resolution, unless it is the designed/desired behavior. (And again, no need to hurry.) |
I actually had a look at your modified sample and got an impression that the problem with it was detected only during NUnit run. The sample itself was a ClassLibrary so I assumed you were interacting with it under NUnit runtime. Is there something that needs to be done with the code to trigger the problem. Or... may be just the sample package was incomplete... |
OK. I guessed. |
OK. All sorted.... You may remember one of our earlier discussions that That's why CS-Script implements a compromised solution. Thus:
I will need to write a dedicated Wiki for the referencing path algorithm. Anyway, your solution can be easily fixed with the following modification: //css_import ..\Forms\FormWithResources.cs;
//css_import ..\..\Properties\Resources.Designer.cs; After: //css_import .\..\Forms\FormWithResources.cs;
//css_import .\..\..\Properties\Resources.Designer.cs; Alternative approach is to configure CS-Script to ALWAYS resolve ALL relative paths with respect to script file (seems like your preferred approach). You can do it as this:
Then, your code will work without any modification. |
I have just added a dedicated section in the https://github.com/oleg-shilo/cs-script/wiki/CLI---User-Guide#hints-and-tips. |
Yes, this explains it. My hosting application does use Thanks for adding it to the wiki. I have also improved the comments where I set From my side, you can close this issue now. One less in the backlog :-)) |
Great. Everyone is happy. :) BTW I a back to empty the backlog. Finally :) Will be engaged mainly with CS-Script.VSCode now. At least for a while. |
Here's the situation using standard settings:
Same situation when explicitly compiling to a .dll file:
Here's the project:
ProjectWithResources.zip
Note that
\Properties\Resources.resx
is properly compiled into\Properties\Resources.resources
(//css_resource ..\Properties\Resources.resx, ..\Properties\Resources.resources;
in\MyScripts\Script.cs
).But compilation of
FormWithResources.resx
failes. Looks like//css_resource
path resolution has an issue with redirection from\MyScripts\Script.cs
to\MyForms\FormWithResources.cs
toFormWithResources.resx
.The text was updated successfully, but these errors were encountered: