I'm setting a Jenkins CI server. I got the first step to run properly:
nuget restore -NonInteractive -ConfigFile Nuget.config -Verbosity Detailed -NoCache
That works properly, but when I want to compile the app with:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe
and ${WorkSpace}\src\Weather.App.csproj
It throws this error:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\NuGet\15.0\Microsoft.NuGet.targets(178,5): error : The package HockeySDK.Core with version 4.1.6 could not be found in C:\WINDOWS\system32\config\systemprofile\.nuget\packages\. Run a NuGet package restore to download the package. [C:\Program Files (x86)\Jenkins\workspace\MyApp\Weather\Weather.App.csproj]
The weird thing is that it the Hockey package clearly exists in the path:
If I run the same command IN my VS2017 local project, everything runs smoothly. But the jenkins server (which is in my same machine) does not build it properly.
Any ideas? Thanks
Here's the trick.
Put nuget.exe somewhere on he build server.
Ensure nuget.exe is in the PATH environment variable.
Restart Jenkins so that it picks up the updated PATH environment variable
Upgrade NuGet to the latest version
nuget.exe update --self
In the Jenkins job calling rebuild against MSBUILD won't successfully restore the nuget packages
Add a Windows Batch step after the MSBUILD Clean and before the MSBUILD Rebuild like so:
nuget restore <your_solution_file>.sln
Path to solution file is workspace relative.
This will create the packages directory as you would expect.
Related
When I build .NET Standard 2.0 Library on Jenkins build server
C:\Program Files\dotnet\sdk\2.1.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error : Assets file 'C:\Jenkins\workspace\<Project>\Sources\Library\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. [C:\Jenkins\workspace\<Project>\Sources\Library\Library.csproj]
I got an error above in build log.
I searched about error and I found solution
However, when running:
dotnet restore <Solution Name>
the solution does not help me out when I clean my workspace before build starts.
Therefore, I insert command before MSBuild but I failed with
C:\Program Files\dotnet\sdk\2.1.302\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error : Package Microsoft.CodeAnalysis.CSharp.Workspaces, version 2.8.0 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. [C:\Jenkins\workspace\<Project>\Sources\Web\Web.csproj]
According to Solution reference, maybe upgrade Nuget Package Installer could help me out. But I do not know how can I upgrade Nuget Package Installer by command line...
I had the same problem, getting the same error:
error : Package <package> was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. [<path>]
I was able to solve it using MSBuild /t:restore instead of dotnet restore.
See: https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target
UPDATE: It's worth mentioning that problems in Jenkins are discussed in depth in this other answer.
The hint by #Mat didn't work for me: the /t:restore is currently not able to restore nuget packages for projects using package.config, as I mention here. What worked for me is the following:
call "%PROGRAMFILES(X86)%\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat"
nuget restore CodeBinder.sln
MSBuild Solution.sln /p:Configuration=Release /p:Platform="Any CPU" /t:build /restore
pause
It basically requires to download the nuget CLI from official site[1], Windows x86 Commandline section. The switch /restore , as pointed here, fixed the partially completed Nuget restore error, similarly to MSBuild /t:restore, but it can be done in conjunction with /t:build.
[1] https://www.nuget.org/downloads
When I build my .NET Solution in Jenkins and try to restore NuGet packages before the actual MSBuild step I'm getting this error:
C:\Program Files\dotnet\sdk\2.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(198,5): error : Package JetBrains.Annotations, version 11.1.0 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions. [PATHLENGHT = 86]
I'm using MSBuild 15 and NuGet Windows x86 Commandline nuget.exe v4.7.0
Any ideas?
Cheers
Since this was a .Net Standard Project, i need to add this command to make it a successful build:
/t:restore
I have inherited a bunch of VS2010 (argh!) installer projects (.vdproj) that install some Win Services
Ofcourse in VS2017 those don't exist anymore but the extension 'VS2017 Installer Projects' works great. I can just open them fine and build, which produces the msi files.
However this needs to be done on the Jenkins machine (running Windows 7) as well. So I installed VS2017 on the Jenkins machine with the Project Installer extension and tried to first run the project from the IDE. Works great. Produces the .msi without problem.
Then I tried to run it from a command line:
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\devenv.exe"
D:\ServiceInstaller\xxxServiceInstaller.vdproj /build
And it does NOT produce anything. Am I trying to do something that is not possible?
There are all kinds of long term solutions of course such as TopShelf, AdvancedInstaller, WIX etc with nice Jenkins plugins but for now it would be nice if I could make this work.
I've made following batch file to call with solution file parameter:
CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat"
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\VSI\DisableOutOfProcBuild\DisableOutOfProcBuild.exe"
devenv /rebuild "Release|Win32" %1
Also make sure that in Visual Studio Configuration Manager Setup build is enabled.
I am trying to build UWP app (targeting 16299) from command line from Jenkins setup.
The system has only VS build tools 2017.
used this command to build
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe" /t:Rebuild /p:Configuration=Release;AppxBundle=Always;AppxBundlePlatforms="x86\x64\ARM" /p:BuildAppxUploadPackageForUap=true SOLUTION_FILE.sln
error MSB4226: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSharp.targets" was not found. Also, tried to find "Microsoft\WindowsXaml\v15.0\Microsoft.Windows.UI.Xaml.CSharp.targets" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths are defined in "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe.Config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths.
Another issue found is nuget is not restoring any package, so updated nuget to 4.4.1 then I got the error
MSBuild auto-detection: using msbuild version '15.5.180.51428' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\bin'.
Nothing to do. None of the projects in this solution specify any packages for NuGet to restore.
same issue with nuget 4.6.0 also
I tried by adding following in project file
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle> </PropertyGroup>
same issue with msbuild and nuget, anyone succeed in building UWP in Jenkins?
Update 05-01-2015
Followed instruction according to answer.
Copied NuGet folder
Copied the "WindowsXaml" folder.
Used MSbuild restore instead of Nuget restore to fix msbuild trying to find packages in "C:\WINDOWS\system32\config\systemprofile.nuget\packages\"
With all these changes no more issues in build,
But the appx bundle is not present. may be individual appx for x86/x64/ARM has to be created and then some kind of merging i s required.
so need further investigations
From the directory path that you have for MSBuild, I see that you may have installed MSBuildTools installer instead of the community, professional,... editions.
I tried that before and found that it's incomplete and doesn't have all dependencies for building Uwp tools, take a look at some of the comments here about the issues.
First Workaround: You can install Uwp Workload from VS Community or Professional as it has all dependencies, till Microsoft fix the issues in BuildTools installer.
Bonus: if you want to run the installer from command line, you can compose command line like that:
vs_installer.exe --installPath "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools" ^
--add Microsoft.VisualStudio.Workload.Universal ^
--add Microsoft.VisualStudio.Component.Windows10SDK.14393 ^
--add Microsoft.Component.MSBuild ^
--passive --wait --norestart
The longer workaround, I managed to install other dependencies but I believe it's kind of hassle if you are automating this installation, snippets from this article
Copy the Sdks folder from a machine that has VS2017 installed at:
c:\Program Files(x86)\Visual Studio\2017\Professional\Build MSBuild\Sdks
to your build machine at:
c:\Program Files(x86)\Visual Studio\2017\Build Tools\MSBuild\Sdks
And for the nuggets issue:
Copying the NuGet import files will do the tr Again, from a machine
with VS2017, copy the following folder: C:\Program Files
(x86)\Microsoft Visual
Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\NuGet
to your build machine at: C:\Program Files (x86)\Microsoft Visual
Studio\2017\BuildTools\Common7\IDE\CommonExtensions\Microsoft\NuGet
Note: If you come by this later and found that Microsoft fixed the issues related to Uwp in MSBuildTools installer, please leave a comment about it in this answer to update it.
I am currently building a continuous integration pipeline on an iMac in order to build Xamarin iOS apps. We are using Jenkins to control the CI build process but the project contains a number of Nuget packages that are not stored in our Git source repo. As these packages are not downloaded by Jenkins I need to call a Restore on the solution.
Is Nuget.exe installed as part of Xamarin Studio on OSX (and if so where) and if not is there an OSX command line version for El Capitan?
The Mono installer on OS-X supplies a nuget shell script and the nuget.exe CIL-assembly
Default install location of script:
/usr/local/bin/nuget
Script contents:
#!/bin/sh
exec /Library/Frameworks/Mono.framework/Versions/4.4.0/bin/mono $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/4.4.0/lib/mono/nuget/NuGet.exe "$#"
Nuget version:
As of Mono 4.4.0, the nuget version is:
NuGet Version: 2.8.5.0
Nuget restore:
In the root of your solution, all you have to do is call nuget restore with your solution, i.e.
>nuget restore mysolution.sln
All packages listed in packages.config are already installed