Illegal characters in path for nuget pack - msbuild

I'm packing an application using Cruise Control, the command is like this
<Exec Command="$(NugetToolPath) pack "#(NuSpecs)" -OutputDirectory \\servername\PackageSource -BasePath "%(NuSpecs.RootDir)%(NuSpecs.Directory)" -NoPackageAnalysis" />
Iv'e narrowed down the error to be the BasePath it comes out as
-BasePath "D:\Code\Mobile_Trunk\PreCompiledWeb\Portal\Mobile LT Admin\"
I know the issue because it should be
-BasePath "D:\Code\Mobile_Trunk\PreCompiledWeb\Portal\Mobile LT Admin"
but because I'm using .Directory metadata it will always return with a \ at the end
I normally wouldn't quote the base path, but since there are spaces in the directory, I have no choice. Is there a way around this? I don't know any other metadata which will return the full folder strucutre other than how I've layed it out
UPDATE:
I came to this solution, it's still not helped my knowledge on how to get around the issue with the illegal path, but it works.
<Exec Command="$(NugetToolPath) pack "%(NuSpecs.RootDir)%(NuSpecs.Directory)%(Nuspecs.FileName).nuspec" -OutputDirectory \\servername\PackageSource -NoPackageAnalysis" />

Just insert a space after the directory and before the quote character:
-OutputDirectory "\\servername\PackageSource\ "
See the accepted answer here (the question itself isn't highly relevant but the answer is):
How to accept command-line args ending in backslash
This fascinating reference is also linked to in another answer on that question:
http://www.daviddeley.com/autohotkey/parameters/parameters.htm#WINCRULESDOC

We got this error when we executed nuget restore from Jenkins, where we ran a JNLP agent on the slave-node.
Turns out that "Path" in Illegal characters in path means the PATH environment variable, and in our case nuget.exe was inheriting a PATH variable that had quotes in it, i.e. something like:
Path=C:\Program Files\foo;"C:\Program Files\bar"
If you are using Jenkins, add echo %PATH% to be executed somewhere by Jenkins, and check if it has any funny characters.

I faced this problem and the error message wasn't too helpful - it did not print out the offending line or path. I had to take out pieces of the config where I suspected the issue might be until I could get to the offending line (removing the offending line allowed the build to pass).
Turns out the offending line had a variable that was blank (I used the Message task to print it out). From there, I was able set the variable to what my project expected.

Related

WSL can't detect VS code

At first, I tried to fix my problem of npm instruction
so I added
[interop]
appendWindowsPath = false
to /etc/wsl.conf
It works, but another problem happen.
When I type code .
Command 'code' not found, did you mean:
command 'node' from deb nodejs (12.22.9~dfsg-1ubuntu3)
command 'cdde' from deb cdde (0.3.1-1build1)
command 'ode' from deb plotutils (2.6-11)
command 'tcode' from deb emboss (6.6.0+dfsg-11ubuntu1)
command 'cde' from deb cde (0.1+git9-g551e54d-1.2)
Try: sudo apt install <deb name>
The above Error message appear.
I tried the following instruction
export PATH=$PATH:"/mnt/c/Users/%USERNAME%/AppData/Local/Programs/Microsoft VS Code/bin"
It also works properly.
Whenever I restarted WSL, npm instruction still worked well, but code instruction lost its function again.
What should I do to fix the problem?
Thanks in advance!
My main suggestion would be to not use appendWindowsPath = false to fix your NPM problem. That's like using a sledgehammer as a flyswatter. As I said in this answer:
Please do not follow the recommendations (like this answer) to completely remove all Windows paths from WSL, as that will severely limit your ability to run Windows applications in WSL (one of its great features).
You'll also lose access to the ability to run PowerShell scripts and commands in WSL easily. You won't have direct access to wsl.exe itself from inside WSL (which comes in handy).
You can type the full paths to these commands, of course, but most instructions and other answers you find here are going to assume that you've left the Windows path intact.
Instead, figure out where npm is installed in your WSL distribution and then determine why it is further toward the end of the PATH than your Windows directories. Windows paths are added at the end of the Linux PATH for a reason. If something in your startup files is adding to the path, it should put it at the beginning, so it has precedence. E.g.:
export PATH="newdir:$PATH"
Note that I'm not saying that you should change your export statement above since, as mentioned, that Windows path would normally come at the end anyway. It's really not going to matter unless you put another code executable somewhere else in your path.
Whenever I restarted WSL, npm instruction still worked well, but code instruction lost its function again.
If you do want the "quick and dirty" (not recommended) solution, then you can simply add that export command that "makes it work" to your ~/.bashrc. That file is processed each time the Bash shell starts interactively.

package.json not able to locate file

I have added a script in my script section of package.json which is present at root directory
"packagr": "ng-packagr -p src/ng-package.json"
But while running this script using
npm run pacakgr
gives error saying "no such file or directory" and tries to find my file at location
root/ng-package.json
instead of
root/src/ng-package.json
Does we need some configuration to map files?
It was a stupid mistake and it happened because I wrote the command in microsoft word.
When you type - in word and press space-bar it converts that character to something else.
Accidentally I used "–" character instead of "-"
Though python interpreter shows same ascii value for both the characters.

I am trying to open Jmeter by the batch file but it gives me a Windows error

Here is the related error its showing:
java.exe is not a recognized file as an internal or external command,
operable or external command
errorlevel=9009
i was getting the same error on WIndows 8.1(64 bit) and checked java path but it was ok
so i just run my jmeter.bat with Run as Administrator and it worked for me
Many operating systems have an environment variable such as PATH that contains a list of directories (or folders) to be searched when looking for a command to execute. Commands that can be found via the PATH are commonly called external commands. The program that reads the command line or the batch file and invoked the commands may have a number of built in commands, these are commonly called internal commands.
I suggest you examine the PATH (or equivalent) set when your java command executes from the command line and also when execution is attempted from the batch file. Compare the two and make sure the directory containing your java.exe is in the PATH.
Does not work with Java 9 beta:
Running:
C:\java -version
Gives:
java version "9-ea"
Just go into command line and run:
java -jar ApacheJMeter.jar
Set the correct Java Path (installed in your system) in Computer -> Advanced System settings -> Environment Variables -> Ok -> System Variables -> Path
I got the same issue and resolved by following the above steps.
I tried everything, this eventually worked.
Within System Variables:
PATH = "C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.8.0_101\bin"
May help someone.
This error occurs due to the path has not been set properly.
Either you can set it in environmental varialables or right click jmeter .bat file,choose edit set the path their,for reference see the jmeter.apache.org user manuals.
For me, my Java path has a space in it and jmeter said it can't find Java
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
.. I looked at the jmeter.sh script and saw it got the path from "Plugin-Ins" .. onward. I tried just commenting out the exit command after that check in the script .. and then I was able to run jmeter.
So apparently the validation logic has a bug, where the error message about can't find java is in fact not true (if Java is indeed set up correctly), so it can be ignored.
For windows 8.1 Users:
Error when trying to run jmeter.bat
Error message:
Not able to find Java executable or version. Please check your Java installation. errorlevel=2
Press any Key to continue
Resolution:
Right Click jmeter.bat and Run as Administrator.
This worked for me, hope this helps. Good luck
Set the correct JM_LAUNCH variable to java.exe
For Windows XP users set Java environment by following the steps here:
http://www.tutorialspoint.com/jmeter/jmeter_environment.htm
Note the path depends on your installed JDK.
And download the file from:
https://svn.apache.org/repos/asf/jmeter/trunk/bin/jmeter.bat
Then replace your jmeter.bat with the downloaded file.
If you have installed Java and still you get this error, please set the java_home path to below using typing below command in terminal:
export JAVA_HOME="/Library/InternetPlugIns/JavaAppletPlugin.plugin/Contents/Home"
Since I run many versions of Java.. I modified jmeter.bat.
rem JM_START - set this to "start" to launch JMeter in a separate window
rem this is used by the jmeterw.cmd script.
rem
rem =====================================================
setlocal
rem Minimal version to run JMeter
set MINIMAL_VERSION=1.8.0
set PATH=%PATH%;C:\Program Files (x86)\IBM\Java80\jre\bin <<< add This line to jmeter.bat
Copied the JAVA executable from Installed version of Java from C:\Program FilesJava\jdk1.8.0_191\bin and pasted in the folder where the jmeter bat resides and it worked for me.
Not exactly the same issue but somebody might find it helpful
Do not double click jmeter.bat but instead ApacheJMeter.jar in the same directory
For me jmeter.bat run but for a brief moment closing almost immediately and not prompting any error. Above workaround allowed me to start working
if JAVA -version shows as blank or empty in the command prompt (CMD) then you need to clear the all java paths in environment variable and again add JAVA_HOME=C:\Program Files\Java\jdk-11.0.15.1
path= C:\Program Files\Java\jdk-11.0.15.1\bin;
if you see C:\Program Files\Common Files\Oracle\Java\javapath; like this remove this
and try in new CMD prompt then Java -version will work.

Running grunt from MSBuild

This thread (Problem capturing error output) gives you a taste of the problem I'm struggling with. I'm trying to run grunt from MSBuild and the grunt errors are not displayed in the Visual Studio output window. I have a .NET project in Visual Studio Express 2012 for Web. I have imported an external project into the project build file with the IMPORT tag and in the imported project I have an Exec task attempting to run grunt. I obviously want to see the error messages that grunt outputs in my Visual Studio output window without too much fuss.
I found an extremely simple workaround that at least sends the output to a text file.
grunt.cmd > grunt-output.txt
This output file is in my .NET project folder somewhere so a quick refresh and double click allows me to open the output file and see a slightly garbled version of the grunt output in Visual Studio.
As an example I'm running a lint task on the grunt.js file, which contains things which JSHint would object to. I deliberately didn't put a semi-colon after var hello and so you get the error message Missing semicolon.
From the command line I get a nicely formatted error message.
Running "lint:files" (lint) task
Linting grunt.js...ERROR
[L2:C10] Missing semicolon.
var hello
<WARN> Task "lint:files" failed. Use --force to continue. </WARN>
Aborted due to warnings.
When I run it from Visual Studio, the output file contains this cluttered format:
[4mRunning "lint:files" (lint) task[24m
Linting grunt.js...[31mERROR[39m
[31m[[39m[33mL2[39m[31m:[39m[33mC10[39m[31m][39m [33mMissing semicolon.[39m
var hello[31m[7m [27m[39m
[31m<[39m[33mWARN[39m[31m>[39m [33mTask "lint:files" failed. Use --force to continue. [39m [31m</[39m[33mWARN[39m[31m>[39m
[31mAborted due to warnings.[39m
Does anyone recognise what all those square brackets and numbers are doing, and can anyone think of a command line switch or grunt switch or node.js switch that would interpret them and turn them into formatting? The don't look like some kind of encoding, they look more like tags to suggest to the command line environment how to format the message. Please don't suggest running some kind of regular expression replace function. I want something quick and easy otherwise it would become more trouble than it's worth.
UPDATE: this link Output gets cut off if piped into another application is pointing to a problem further upstream in node dating back 10 months. While that's getting sorted out it would be nice to at least get a more readable output file.
This thread on the grunt message board Pipe-redirecting Grunt's output is broken addresses this issue perfectly and provides a quick workaround while we wait for the overall issue to get fixed. They are escape codes to colour the output and the workaround is to use the --no-color option to remove colouring.
When I run this command from MSBuild
grunt.cmd --no-color > grunt-output.txt
I get nicely formatted output with exactly the same content as the command line:
Running "lint:files" (lint) task
Linting grunt.js...ERROR
[L2:C10] Missing semicolon.
var hello
<WARN> Task "lint:files" failed. Use --force to continue. </WARN>
Aborted due to warnings.
I can live without the colour. It would be nice if this could be sent to the output window, though, because MSBuild throws what seems like an error in the build process when in fact it's just JSHint tactfully hurting my feelings about my JavaScript.
In response to "I obviously want to see the error messages that grunt outputs in my Visual Studio output window without too much fuss."
I'd have a look at VsCommandBuddy ... it helps you integrate your grunt (and any other command for that matter) right inside visual studio. Commands are configured per solution/project, and at the time of this writing are being made available via menus, toolbar, shortcuts and the quicklaunch ...
http://visualstudiogallery.msdn.microsoft.com/f5da988e-2ec1-4061-a569-46d09733c668
It's a scratch-my-own-itch project. It helps me getting thins done. In every solution I open in visual studio, I simply get presented al the external commands I put togheter for that solution / or porject.
Output goes thorugh the outputwindow as desired. The no-color option for grunt removes all the noise.
Hope it helps!!

MSBuild Error Failed to read in data for

I have read numerous MSBuild posts, but none seem to refer to a strange problem I am having.
In MSBuild.xml (.NET 3.5) I have the following:
<ItemGroup>
<JavaScriptFiles Include="..\js\jquery.translator-ms-1.0.0-debug-all.js" />
</ItemGroup>
I receive an error:
Error 188 Failed to read in the data for the path/file [..\js\jquery.translator-ms-1.0.0-debug-all.js]. The most common cause for this is because the path is incorrect or the file name is incorrect ... so please check your path and file names.
However, if I use a file in the very same folder as follows with like properties:
The build completes successfully.
Does anyone know the "uncommon" causes for this error?
Possible reasons for being unable to open and/or read a file:
It doesn't exist.
It is open in another process (either for exclusive access, or it's locked).
You don't have NTFS permissions.
You want write access but the file has the read-only attribute.
The combined length of the path and (your quite long) filename exceeds MAX_PATH (260) characters.
The file is on a remote server and there's a network problem.
You've run out of kernel resources (e.g. too many files or handles in general open). This is quite unlikely.
You have a physical disk error.
It turns out that having the "debugger" statement within this JavaScript file was the "uncommon" error in this case.