After updating to Visual Studio 2013 Update 3, the following code in a T4 template breaks.
<## include file="../File1.tt" #>
It worked as expected in all previous versions of VS.
With this Update, all the variants:
<## include file="../File1.tt" #>
<## include file="..\File1.tt" #>
<## include file="..\\File1.tt" #>
Fails with the following error:
There was an error loading the include file '..\\File1.tt'. The transformation will not be run. The following Exception was thrown:
System.ArgumentException: The path is not of a legal form.
at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.Path.GetFullPath(String path)
at Microsoft.VisualStudio.TextTemplating.Engine.VisitedFiles.Visit(String fileLocation)
at Microsoft.VisualStudio.TextTemplating.Engine.ProcessIncludeDirective(Directive directive, ITextTemplatingEngineHost host, VisitedFiles includedFiles) in line: 234 in file: C:\...\mytemplate.tt
Any known workaround or fix for this issue?
Root cause found.
When implementing the interface ITextTemplatingEngineHost one of the method to implement is:
public bool LoadIncludeText(
string requestFileName, out string content, out string location)
In all previous versions before VS2013 Update 3 returning a valid filename in the location parameter as output was not required. In fact, we send string.Empty.
Accordingly to the documentation the value can be empty if the template is not file-system based. See doc reference:
location Type: String
A String that contains the location of the
acquired text. If the host searches the registry for the location of
include files or if the host searches multiple locations by default,
the host can return the final path of the include file in this
parameter. The host can set the location to Empty if the file could
not be found or if the host is not file-system based.
However with Update 3, something has changed and T4 engine checks and expects the location parameter to be a non-empty file path. String.Empty value result in the original commented exception.
As a temporal workaround: passing a valid file name to the location parameter on method LoadIncludeText when implementing ITextTemplateEngineHost avoids the exception.
Thanks to #rubenjmarrufo in the hunt for the bug.
Update: Confirmed bug by Microsoft. It will be fixed on Update 4. Commented workaround is valid.
Related
I'm trying to configure a debugger for my project.
Here is the problem.
The project folder structure can be simplified like this:
- Project Root
- X
- Y
- etc
I absolutely need to set the cwd in the debugger config as X, otherwise the binary won't run. If I set it as X, program runs, debugger (sort of) works: I see the call stack and the values of the variables. However, vscode cannot find the files with code and I can't see the lines being executed. VSCode also gives me an error:
Unable to open 'file.cpp':
Unable to read file '/blahblah/cwd/Y/file.cpp'
Error: unable to resolve non-existing file.
So the debugger rightfully uses the cwd as a prefix to the rest of the file path, but Y is not nested into X, it is actually in the same root directory.
Again, I absolutely need the binary to be called from the X directory. Is there any way to tell vscode the proper path to the code files in this case?
So here is what worked for me:
// added this to launch.json
"sourceFileMap: {
"proc/self/cwd" : "{workspaceFolder}"
}
From the VSCode docs:
sourceFileMap:
This allows mapping of the compile-time paths for source
to local source locations. It is an object of key/value pairs and will
resolve the first string-matched path. (example: "sourceFileMap": {
"/mnt/c": "c:\" } will map any path returned by the debugger that
begins with /mnt/c and convert it to c:\. You can have multiple
mappings in the object but they will be handled in the order
provided.)
My problem was that the directory from which I needed the process to run didn't match the directory where the source files are located. In the error message vscode gave me I saw the path it uses to try to find source files ("/proc/self/cwd"). So I mapped this path to the one I actually need (just the workspaceFolder in my case).
I am new to Java Modularity. I am using Java 9.
The program compiles without complaint. It also runs perfectly well from the "exploded module" folder, but with one exception: it throws an exception whose cause originates with the following line of code:
URL introURL = AboutPanel.class.getResource("help.html");
introURL is being assigned null.
When running the program in Eclipse, or from a jar file exported from Eclipse, the URL is populated correctly with the address of a resource file (help.html) that is in the same directory as the calling class.
Here is the command I use to run the program from the "exploded module" that is in the "out" folder:
java -p out/ -m moduleTCD/com.adonax.tanpura.TCDLaunch
The project consists of two packages that I am bundling together in a single module.
src/moduleTCD/com/adonax/tanpura
/pfaudio
The "main" class (entry point) is tanpura.TCDLaunch.
Here is the module-info.java class contents:
module moduleTCD {
exports com.adonax.tanpura;
requires java.base;
requires java.desktop;
}
The error statement, when trying to run from the command line:
java.io.IOException: invalid url
at java.desktop/javax.swing.JEditorPane.setPage(Unknown Source)
at moduleTCD/com.adonax.tanpura.documentation.AboutPanel.<init>(AboutPanel.java:28)
at moduleTCD/com.adonax.tanpura.panels.ControlPanel.initializeHelpPanel(ControlPanel.java:525)
at moduleTCD/com.adonax.tanpura.panels.ControlPanel.<init>(ControlPanel.java:163)
at moduleTCD/com.adonax.tanpura.TCDLaunch.main(TCDLaunch.java:43)
This exception is thrown in a try/catch for IOException at the point where the JEditorPane method setPage is called with null as an argument.
textArea.setPage(introURL);
At first, I didn't have an exports line in my module-info.java, but added it when I read the following from the API for Class.getResource:
Returns:
A URL object; null if no resource with this name is found, the resource cannot be located by a URL, the resource is in a package that
is not open to at least the caller module, or access to the resource
is denied by the security manager.
This raised the possibility that the package might be needed by Class in the module Java.base. The exports command there now is the broadest possible. But adding it did not change the error. I'm wondering if there is something wrong with how I did this, or if there is something else I am overlooking.
Classic error on my part. I made assumptions about the error being related to tech that is new and unfamiliar to me, rather than first verifying the obvious.
The fail was due to not realizing that the javac command did not move required resources into the target folder system.
I also verified that an "exports" statement is NOT needed in module-info in order to allow the loading of the resource.
So, in fact, this was not a java-module issue at all, just an oversight which I credit in part to a lack of chops using shell-level Java commands.
Big thank you to Alan Bateman!
I am trying to link from our project's extension documentation to the core documentation in Sphinx. I've tried intersphinx, but from what I see it only supports objects, while our documentation doesn't refer to objects, it's just plain .rst.
I've added
intersphinx_mapping = {
'project': ('http://link-to-readthedocs/index.html', None),
}
to conf.py and edited the link to :ref:\`Documentation\` and later :doc:\`Documentation\` . It didn't work.
The question:
How to link from one projects' documentation to another in Sphinx for plain .rst files (not objects)?
Edit: I've done make html, found my objects.inv, but now I guess I only have it locally? I'm not sure what I'm doing anymore, but when I try to check the object references, I get:
UserWarning: intersphinx inventory 'http://myproject.com/index.html/objects.inv' not fetchable due to <class 'urllib.error.HTTPError'>: HTTP Error 404: Not Found
'%s: %s' % (inv, err.__class__, err))
The first thing to fix here is the link you've included to the base URL of your project docs:
intersphinx_mapping = {
'project': ('http://link-to-readthedocs/index.html', None),
}
According to the intersphinx docs:
A dictionary mapping unique identifiers to a tuple (target, inventory). Each target is the base URI of a foreign Sphinx documentation set and can be a local path or an HTTP URI. The inventory indicates where the inventory file can be found: it can be None (at the same location as the base URI) or another local or HTTP URI.
Thus, the error is in having the index.html at the end of your target. It should instead look something like this:
intersphinx_mapping = {
'project': ('http://project.readthedocs.io/en/latest', None),
}
If desired, replace en with the preferred docs language, and latest with the preferred RtD built version of the docs.
while building a project in VisualStudio 2012 I get the error message
LINK : fatal error C1905: Front end and back end not compatible (must target same processor).
Checking the project manually does not help, all involved (static) libraries have been built for the same processor. I also added
/VERBOSE:lib and /VERBOSE
to command line to get some more information but this does not help, only additional output line I got by this was a stupid
Starting pass 1
So: any ideas how I can find out what causes this strange error message? How can I get more output from the linker?
Thanks!
Old question and I'm not sure whether anyone still need an answer. I had this problem with Visual Studio 2017.
Check paths for generated .obj files, especially when you use some .cpp files in more than one project (within solution) and/or use %(RelativeDir) variable in Properties -> C/C++ -> Output Files -> Object File Name. It happened to me with this path in Object File Name '$(IntDir)\%(RelativeDir)' and this $(ProjectDir)Junk\$(Platform)\ in Intermediate Directory. Error gone when I moved $(Platform) part to Object File Name.
Old paths:
Intermediate Directory: $(ProjectDir)Junk\$(Platform)\.
Object File Name: $(IntDir)\%(RelativeDir).
New paths:
Intermediate Directory: $(ProjectDir)Junk\.
Object File Name: $(IntDir)$(Platform)\%(RelativeDir).
You can also specify Object File Name option for each file, shared between multiple projects to keep using old path (or if new paths configuration isn't working for you) and get rid of that error.
I am using WiX 3.5 and making an installer. I have used heat.exe to bundle all the files.
It produced a WiX file. I referred in main wxs files as componentgroup ref. When I build my installer, it throws the following exception.
light.exe : error LGHT0103 : The system cannot find the file
'..........\target\tmp-release\jboss-eap-5.0\jboss-as\server\all\deploy\httpha-invoker.sar\invoker.war\WEB-INF\classes\org\jboss\invocation\http\servlet\ReadOnlyAccessFilter.class'
with type ''.
It is able load many files from this location, except the above file, even though the file is present.
Looks like you've hit the linker bug. As far as I can see, it was already reported to the WiX team, and was scheduled for v4.0. The comment to the issue states the path is more than 255 characters, so a possible workaround for you is to re-work the files/folders layout to avoid the paths of that length.
Hope this helps.
The answer of Ravz1234 works ! I used it with a environment variable e.g. env.SourcePath.
1) Set an environment variable to show on your Source Dir e.g. C:\SourceDir
2) On heat.exe add the argument -var env.SourcePath along with the other arguments
I used the variable for the directory, sys.SOURCEFILEDIR, and it worked well.