Nuget Package Manager Error 'Illegal characters in path.' - visual-studio-2017

I use Visual Studio 2017 and my NuGet Package Manager doesn't work consistently.
I open 2 projects for test this problem with sames properties and same names (Wpfappt, wpfapph) in wpfappt the manager works, but in wpfapph it doesn't.
This is the messages in the output field:
wpfappt (it works):
Restoring packages for C:\Users\Yogev\source\repos\WpfAppt\WpfAppt\WpfAppt.csproj...
GET https://api.nuget.org/v3-flatcontainer/microsoft.office.interop.excel/index.json
OK https://api.nuget.org/v3-flatcontainer/microsoft.office.interop.excel/index.json 822ms
GET https://api.nuget.org/v3-flatcontainer/microsoft.office.interop.excel/15.0.4795.1000/microsoft.office.interop.excel.15.0.4795.1000.nupkg
OK https://api.nuget.org/v3-flatcontainer/microsoft.office.interop.excel/15.0.4795.1000/microsoft.office.interop.excel.15.0.4795.1000.nupkg 185ms
Installing Microsoft.Office.Interop.Excel 15.0.4795.1000.
Committing restore...
Writing lock file to disk. Path: C:\Users\Yogev\source\repos\WpfAppt\WpfAppt\obj\project.assets.json
Restore completed in 3.62 sec for C:\Users\Yogev\source\repos\WpfAppt\WpfAppt\WpfAppt.csproj.
Successfully installed 'Microsoft.Office.Interop.Excel 15.0.4795.1000' to WpfAppt
Executing nuget actions took 3.54 sec
Time Elapsed: 00:00:10.3848087
========== Finished ==========
And this is the message from the other project:
Attempting to gather dependency information for package 'Newtonsoft.Json.10.0.3' with respect to project 'WpfApph', targeting '.NETFramework,Version=v4.6.1'
Gathering dependency information took 754.28 ms
Attempting to resolve dependencies for package 'Newtonsoft.Json.10.0.3' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'Newtonsoft.Json.10.0.3'
Resolved actions to install package 'Newtonsoft.Json.10.0.3'
Retrieving package 'Newtonsoft.Json 10.0.3' from 'nuget.org'.
Adding package 'Newtonsoft.Json.10.0.3' to folder 'C:\Users\Yogev\source\repos\WpfApph\packages'
Added package 'Newtonsoft.Json.10.0.3' to folder 'C:\Users\Yogev\source\repos\WpfApph\packages'
Install failed. Rolling back...
Package 'Newtonsoft.Json.10.0.3' does not exist in project 'WpfApph'
Removing package 'Newtonsoft.Json.10.0.3' from folder 'C:\Users\Yogev\source\repos\WpfApph\packages'
**Removed package 'Newtonsoft.Json.10.0.3' from folder** 'C:\Users\Yogev\source\repos\WpfApph\packages'
Executing nuget actions took 1.1 sec
**An error occurred while writing file** 'C:\Users\Yogev\source\repos\WpfApph\WpfApph\packages.config': Failed to write packages.config as XML file 'C:\Users\Yogev\source\repos\WpfApph\WpfApph\packages.config'. Error: 'Illegal characters in path.'.
Time Elapsed: 00:00:01.8665589
========== Finished ==========
Thank you.

Related

Pants exclude specific Python dependencies

Currently, I am using pants to build and test our python2.7 packages. We started noticing the following error during run goal after pytests goal is completed. I tried adding constraints.txt file to exclude the dependencies its complaining about, but the error wouldn't stop. Is there a way to exclude these dependencies during the pants build step?
./pants test.pytest --coverage=auto tests/python/abcd/test/xyz
[pytest]
[cache]
No cached artifacts for 1 target.
Invalidated 1 target.
[run]
Failed to execute PEX file, missing compatible dependencies for:
importlib-metadata
zipp
No .coverage file was found! Skipping coverage reporting.
tests/python/abcd/test/xyz ..... SUCCESS
FAILURE
Can you try increasing the verbosity with:
PEX_VERBOSE=9 ./pants test.pytest --coverage=auto tests/python/abcd/test/xyz
and then respond here?
This error can be caused by a couple of things. Are you executing the PEX on the same operating system that the PEX was built on? Do you also include platforms=[...] in your python_binary function in your BUILD file?

include sympy library into chaquo

include sympy python packages into Chaquopy:
I started with the example python provided by Chaquopy available at github (https://github.com/chaquo/chaquopy) for Android studio 3.0.1.
Than I created 2 wheel files from the sympy source () files, based on python 3.6.3, see the below files that wheel generated:
"mpmath-1.0.0-py3-none-any.whl"
"sympy-1.1.1-py3-none-any.whl"
I tried to install the above files into the build.gradle of the demo example from 1., for testing purposes I tried some of there own wheel files (that process succeeded), but could not install my own wheel files.
I am fairly certain that the local wheel files that I generated are placed in the proper directory, because if I change the directory in the gradle file it complains that it cannot find the file.
I included the wheel files in the build.gradle(Module:app) file as follows:
python {
// Enable and edit the following line if "python" is not on your PATH.
// buildPython "C:/Python27/python.exe"
version "3.6.3"
// Android UI demo
pip {
install "Pygments==2.2.0" // Also used in Java API demo
}
pip {
install "wheels/mpmath-1.0.0-py3-none-any.whl"
// install "wheels/sympy-1.1.1-py3-none-any.whl"
// install "numpy==1.9.2"
// install "numpy==1.14.0"
}
When created the build gradle generates the following error:
sympy-1.1.1-py3-none-any.whl is not a supported wheel on this platform.
Exit status 1
:app:generatePy2DebugPythonRequirements FAILED
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:generatePy2DebugPythonRequirements'.
Process 'command 'python'' finished with non-zero exit value 1
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Get more help at https://help.gradle.org
BUILD FAILED in 2s
7 actionable tasks: 1 executed, 6 up-to-date
Does anyone have an idea what could be wrong?
sympy and mpmath have now been added to the Chaquopy wheel repository (https://github.com/chaquo/chaquopy/issues/20), so you don't need to build your own anymore.
Did some further investigation and did see that I somehow compiled for Py2, while my wheel files where version 3 changing this resulted in a correct executable.
It did run into a different issue, while the mpmath module could be imported into the interactive python console (part of the demo app), the sympy module gave an error:
ModuleNotFoundError: no module named 'distutils'
Let me know if anyone ran into a similar problem!

Could not load file or assembly System.Reflection.TypeExtensions

I got below exception while running xunit test projects which works under VS 2017 15.3
[2017/12/4 23:08:40 Error] [xUnit.net 00:00:00.0033291] xxx.Test: Catastrophic failure: System.TypeInitializationException: The type initializer for 'Xunit.DiaSession' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Reflection.TypeExtensions, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
at Xunit.DiaSession..cctor()
--- End of inner exception stack trace ---
at Xunit.DiaSession..ctor(String assemblyFileName)
at Xunit.DiaSessionWrapper..ctor(String assemblyFilename)
at Xunit.XunitFrontController..ctor(AppDomainSupport appDomainSupport, String assemblyFileName, String configFileName, Boolean shadowCopy, String shadowCopyFolder, ISourceInformationProvider sourceInformationProvider, IMessageSink diagnosticMessageSink)
at Xunit.Runner.VisualStudio.TestAdapter.VsTestRunner.RunTestsInAssembly(IRunContext runContext, IFrameworkHandle frameworkHandle, LoggerHelper logger, IMessageSinkWithTypes reporterMessageHandler, AssemblyRunInfo runInfo)
My current VS 2017 version is 15.4.5.
I have tried the work around which has been provided previously, but none did not work. And I have try to downgrade my VS 2016 to 15.3, but I could not find the 15.3 package to install. I have tried to install xunit to latest version.
Any help would be appreciated.
Update:
Project Type:xUnit Test Project(.NET Core)
Target: net 461
It seems VS 2017 fail to load specific "xunit.runner.visualstudio", after checking VS2017 15.4.2 - Unable to run tests for projects targeting .NET Framework 4.6.x #1542 again, I deleted the "%TEMP%\VisualStudioTestExplorerExtensions", create a new Xunit project, change the nonworked.csproj xunit.runner.visualstudio from 2.2.0 to 2.3.1, it works now. Not sure why it did not work when I try it previous.
Hope it will help others.
You need to install System.Reflection.TypeExtensions using VS Package Manager using the following command:
Install-Package System.Reflection.TypeExtensions -Version 4.5.1
for more information please review the following link
System.Reflection.TypeExtensions

nuget restore failing in team services build

I have 2 local assemblies referenced via nuget (packed the dll's up) using vs2017 on a asp.net core solution, builds fine locally.
Now trying to generate a build via VSTS i am getting the following error,
Detected NuGet version 4.0.0.2283 / 4.0.0
SYSTEMVSSCONNECTION exists true
Saving NuGet.config to a temporary config file.
d:\a\_tool\NuGet\4.0.0\x64\nuget.exe restore d:\a\1\s\TestFrameworkCoreAPI.sln -Verbosity Detailed -NonInteractive -ConfigFile d:\a\1\Nuget\tempNuGet_37.config
NuGet Version: 4.0.0.2283
MSBuild auto-detection: using msbuild version '15.3.409.57025' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
MSBuild P2P timeout [ms]: 120000
C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin\msbuild.exe /t:GenerateRestoreGraphFile /nologo /nr:false /p:RestoreUseCustomAfterTargets=true /p:BuildProjectReferences=false /v:q /p:NuGetRestoreTargets="d:\a\_temp\NuGet-Scratch\w53qa5rr.4sd.targets" /p:RestoreTaskAssemblyFile="d:\a\_tool\NuGet\4.0.0\x64\nuget.exe" /p:RestoreGraphOutputPath="d:\a\_temp\NuGet-Scratch\4mlmlfgh.mmy.result" /p:ExcludeRestorePackageImports=true /p:RestoreRecursive=False /p:RestoreProjectFilterMode=exclusionlist /p:RestoreContinueOnError=WarnAndContinue /p:RestoreGraphProjectInput="d:\a\1\s\TestFrameworkCoreAPI\TestFrameworkCoreAPI.csproj;" "d:\a\_temp\NuGet-Scratch\w53qa5rr.4sd.targets"
Running restore with 2 concurrent jobs.
Reading project file d:\a\1\s\TestFrameworkCoreAPI\TestFrameworkCoreAPI.csproj.
Reading project file d:\a\1\s\TestFrameworkCoreAPI\TestFrameworkCoreAPI.csproj.
Restoring packages for d:\a\1\s\TestFrameworkCoreAPI\TestFrameworkCoreAPI.csproj...
Restoring packages for d:\a\1\s\TestFrameworkCoreAPI\TestFrameworkCoreAPI.csproj...
Restoring packages for .NETCoreApp,Version=v1.1...
Restoring packages for .NETCoreApp,Version=v2.0...
System.AggregateException: One or more errors occurred. ---> NuGet.Protocol.Core.Types.FatalProtocolException: Failed to retrieve information about 'Microsoft.VisualStudio.Web.CodeGeneration.Tools' from remote source 'D:\TestFrameworkAssemblies'.
at NuGet.Protocol.LocalV3FindPackageByIdResource.GetVersionsCore(String id, ILogger logger)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at NuGet.Protocol.LocalV3FindPackageByIdResource.GetAllVersionsAsync(String id, SourceCacheContext cacheContext, ILogger logger, CancellationToken token)
at NuGet.Commands.SourceRepositoryDependencyProvider.<FindLibraryAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
Error: d:\a\_tool\NuGet\4.0.0\x64\nuget.exe failed with return code: 1
Packages failed to restore
I have a nuget.config file in a .nuget folder located in the root of solution,
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!-- remove any machine-wide sources with <clear/> -->
<clear />
<add key="Test Framework" value="D:\TestFrameworkAssemblies" />
<add key="nuget.org" value="https://www.nuget.org/api/v2/" />
</packageSources>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
This is what is in the VSTS build def, NuGet restore step
It looks like it always references my local assembly and not the standard nuget.org, now in the config file, if i take out my local entry to framework assemblies, the nuget part works but i get a primary reference error as it cannot find the 2 assemblies i have packed locally.
Been going round in circles with this at the moment, how can you get VSTS to restore local packed assemblies as well as from nuget.org. I am using Hosted 2017 as well.
thanks in advance
It seems you were queue the build on Hosted agent. Since there has the packages located on your local machine, you should build with the private agent which located on your local machine.
Additional, if you need to queue the build on Hosted agent, you should add the local packages in repository, and then reference the packages with the new path and change the value in nuget.config.

Not able to build .net solution in Team city by using Nant.exe

I have using team city to build my project by using of Nant as build. So I have created one batch file in to build my project by where I using Nant.exe which is responsible for build my solution.
When I am ruing this batch file from command prompt I am successfully able to build my solution. But When I run the same file from TeamCity its giving me Build fail error.
So That I have verified path and that also correct. Below are the path I have stored in team city.
Path to a build file: Build.bat (bat file for build)
Working directly : D:\CMS (path where my bat file is located.
NAnt home: Path were Nant exe located.
Targeted framwork : Net 4.0
When I am ruing this build by team city every time build fails with below log generated.
[21:27:54]: Checking for changes
[21:27:55]: Clearing temporary directory: C:\TeamCity\buildAgent\temp\buildTmp
[21:27:55]: Checkout directory: D:\Projects\JoyaCMS\src
[21:27:56]: Repository sources transferred
[21:27:55]: Updating sources: server side checkout... (1s)
[21:27:57]: Publishing internal artifacts (2s)
[21:27:57]: Starting: D:\Projects\JoyaCMS\src\UppercuT\lib\NAnt\NAnt.exe - buildfile:D:\Projects\JoyaCMS\src\build.bat -targetframework:net-4.0 - extension:C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NAntLoggers .dll -listener:JetBrains.BuildServer.NAntLoggers.NAntListener
[21:27:57]: in directory: D:\Projects\JoyaCMS\src
[21:27:57]: Process exited with code 1
[21:27:57]: NAnt output:
[21:27:57]: NAnt 0.91 (Build 0.91.3881.0; alpha2; 8/17/2010)
[21:27:57]: Copyright (C) 2001-2010 Gerry Shaw
[21:27:57]: http://nant.sourceforge.net
[21:27:57]: BUILD FAILED
[21:27:57]: For more information regarding the cause of the build failure, run the build again in debug mode.
[21:27:57]: Try 'nant -help' for more information
[21:27:57]: D:\Projects\JoyaCMS\src\build.bat(1,1):
[21:27:57]: Error loading buildfile.
[21:27:57]: Data at the root level is invalid. Line 1, position 1.
[21:28:02]: Publishing internal artifacts (1s)
[21:28:05]: Build finished
So let me know how can I resolve this issue in team city. and what setting I need to perform more to resolve this issue.
Thanks,
Amit
First of all I noticed a few occurrences of additional whitespace characters in your NAnt call e.g.- extension:C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NAntLoggers .dll. Might be an SO formatting issue, but in case they're part of your batch, remove them first.
If this doesn't help, activate verbose build output via NAnt switch -v+. That should give more information.