NuGet/MyGet debug throws source code not found error - debugging

We are trying to adapt Nuget package way for our project. All is well till we hit debugging problem. Here is the situation:
Created New project and created nuget package with symbols
Pushed both nuget package and symbols to MyGet Server. I could see source files are listed in myget server.
Set Options -> Debugging -> General - Uncheck Enable just my code
Set Options -> Debugging -> Symbols to MyGet Server url
Also set Cache symbols in local folder
Set Options -> NuGet Package Manager -> Package manager sources to MyGet Server
In my Test project, I could see my Nuget package and debug working fine as source code is in same machine
On Client machine (Another machine), created test project and try to debug the package and it is throwing cs file not found error.
When I check the Cache symbols local folder I see only .pdb file downloaded, but no files from src folder are downloaded - where all the cs files are available.
Am I missing anything in this? Why my debug is failing why Visual Studio 2017 not downloading src files from myget server?

Related

MSB4019 VSTO targets not found TeamCity build agent

I'm using a TeamCity build server to try and build an Outlook Addin, I can build & test the code using TeamCity, but when it comes to publishing the app to a folder I get the following error.
Obviously the build server is missing some SDK components to complete the package\publish step.
Does anyone know which Windows SDK I need to get installed on the build server?
Nothing to do. None of the projects specified contain packages to restore.
XXXXXXXX.Outlook.csproj(331,3): error MSB4019:
The imported project "C:\Program Files\dotnet\sdk\7.0.102\Microsoft\VisualStudio\v17.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" was not found.
Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\7.0.102\Microsoft\VisualStudio\v17.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" is correct, and that the file exists on disk.
Build FAILED.

Visual studio 2019: Adding, Updating or Deleting Package Source Has No Effect

I had a package source named MyMyGetFeed, I changed its URL but it still looking at the old one, even after deleting it I can still see that visual studio is looking into it as shown in the error message below, I'd also tried to create new package source with the new URL and it is still showing the same error neglegting my new source. Cleaning project, restarting Visual Studio and even deleting NuGet.Config file didn't help. Any Ideas please?
Severity Code Description Project File Line Suppression State
Error NU1102 Unable to find package Synergix.WE.Security.Cryptography with version (>= 2.1.3)
- Found 3 version(s) in MyMyGetFeed [ Nearest version: 2.1.2 ]
- Found 0 version(s) in nuget.org Synergix.ADCE.Client.Service.Commands C:\Users\MOHAMMAD\source\repos\adce.client\src\Service\Synergix.ADCE.Client.Service.Commands\Synergix.ADCE.Client.Service.Commands.csproj 1
Visual studio 2019: Adding, Updating or Deleting Package Source Has No
Effect
First, if you add the new package source by Tools-->Options-->Nuget Package Manager-->Package Sources(global nuget.config file), you should make sure that there is no other custom nuget.config in your solution explorer to affect the global nuget.config file. See this.
Besides, you can follow the below steps to troubleshoot your issue:
you should make sure that the new package source url is enable and the old package source url is deleted or unchecked like this:
In global nuget.config file(C:\Users\<User>\AppData\Roaming\NuGet\) like this:
<packageSources>
<add key="new package source" value="C:\xxxxxx" />
<add key="old package source" value="C:\xxxxxxx" />
</packageSources>
<disabledPackageSources>
<add key="old package source" value="true" />
</disabledPackageSources>
From the error message, it searches for version 2.1.3, so make sure that Synergix.WE.Security.Cryptography 2.1.3 is in the new package source url and you have the right to access the new package source. To test it, you can copy the link in website to see whether it can return any request.
clean nuget caches under Tools-->Options-->Nuget Package Manager-->General-->Clear All Nuget Caches or just delete the packages folder under C:\Users\xxxx\.nuget.
And run nuget locals all -clear under Tools-->Nuget Package Manager-->Package Manager Console
disable any third party extensions under Extensions-->Manage Extensions in case it causes this abnormal behavior.
close VS instance, delete .vs hidden folder, bin, obj folder, 'Nuget.Config' file under C:\Users\<User>\AppData\Roaming\NuGet\(will recreate automatically when restart VS)
and then run VS as administrator to test whether the issue persists.
In addition, try to create a new default project and then install this package to test whether the issue is your project itself or is the nuget tool.

How to disable "transitive package management" for a Visual Studio project

How do I disable "transitive package management"?
I wish to do so, so that I can install a package that I "packed" locally and have in a .nupkg file. When I attempt to do so, I get a messaging stating that The 'Source' parameter is not respected for the transitive package management based project(s) {csproj file}. The enabled sources in your NuGet configuration will be used.
Complete Context
When developing a NuGet package that's not ready for distribution via our NuGet feed, I often create a local .nupkg file like this from the package manager console:
nuget pack {path-to-csproj-file}
This generates a {project-name}.nupkg file, which I can then install in another project by opening it in Visual Studio, navigating to the package manager console, and entering the command
Install-Package {path-to-nupkg-file}
This has worked great and once the NuGet package is ready for distribution, we push it up to Azure DevOps and let the build pipeline there push it into our feed.
However, I just recently inherited a project where the prior developer apparently setup "transitive package management" that prevents this workflow. Here's what I get when I try to install directly from a .nupkg file:
Install-Package C:\Users\Josh\source\repos\SpeakerDiscountManager\SpeakerDiscountData.1.0.5.nupkg
The 'Source' parameter is not respected for the transitive package management based project(s) MembershipApplicationWidget\MembershipApplicationWidget.csproj. The enabled sources in your NuGet configuration will be used.
<snipped several lines of unsuccessfully searching configured package sources>
Install-Package : NU1102: Unable to find package SpeakerDiscountData with version (>= 1.0.5)
Obviously, it doesn't find the package I've specified via file, because it is searching online feeds and it doesn't exist in any of our online package sources--the package is in a testing state, not ready for anyone to use but me.
Based on the error message, I need to turn off "transitive package management" so that I can specify a file source for the package, but I've been unable to turn up any information online about how this is configured.
I did try installing this exact same .nupkg file in another project, using the same Install-Package {path-to-nupkg-file} procedure. This works.
How to disable “transitive package management” for a Visual Studio
project
I think this problem transitive package management is related to your current project structure which has some intricate dependencies, custom rules and so on. Therefore, turning off transitive package management is unpractical. If you create other projects and then install this package by your way, I think it probably will not occur.
As a best workaround, as you said(hint from the message The enabled sources in your NuGet configuration will be used.), add the the local nuget package's path into Nuget Package Source.
In your side, I think you specify -Source xxxxx(the path of the nuget package) to install this package in the package manager console, if so, this function actually is inconvenient.
You can just add the folder path which SpeakerDiscountData.1.0.5.nupkg exists into global nuget package source. Once you have done it, it will applies to any projects in this machine.
It has two ways:
1) VS IDE UI
Tools-->Options-->NuGet Package Manager-->Packages Sources-->add a new key and input the path of the nuget folder. Also, check its option.
2) global NuGet.Config file
(C:\Users\xxxx\AppData\Roaming\NuGet\Nuget.Config and step 1 is just add the path into this file by VS UI Control)
add these:
<packageSources>
<add key="Local Packages Source" value="C:\Users\Josh\source\repos\SpeakerDiscountManager\" />
..........
</packageSources>
After that, you can use your command to install this nuget package.
Note: If the root directory of your solution also has a file named nuget.config, the parameters in it will override the global file. It has the highest priority.
Just go to Vs IDE Tools/Nuget Package Manager/Package Manager Setting And Check The address of Package Sources.
it's something like "C:\Program Files (x86)\Microsoft SDKs\NuGetPackages".
Then Copy your package file into that folder and at last run this command in Package Manager Console:
install-package packagename

ProGet symbols and source server: download pdb correctly but source not found

I have a problem reguarding the source files and symbols using ProGet and VS2017/VS2019.
My scenario is the following
Develop test assembly on my pc
Push mod files on our git server
Get mod files in our TeamCity (2019.1)
Build source in Release mode, pack and publish the AssemblyTest.symbols.nupkg on ProGet (5.2.3)
In VS2017 I've create a test console app, install the AssemblyTest via Package Reference and I've tried simply to press F12 on the class in my code to show the source code or step in in debug mode.
I've configure VS2017 as the guide suggests here
The nuget pack command was launched with -symbols command line parameter and the symbol.nupkg was created with the following stucture
package
service
metadata
...
lib
net472
TestAssembly.dll
TestAssembly.pdb
TestAssembly.xml
src
Properties
AssemblyInfo.cs
TestClass.cs
Pressing F12 on TestClass in my code the pdb was correctly downloaded in
c:\users\me\appdata\local\temp\symbolcache\testassembly.pdb\bf5be5cd155e4400b9b18c0e1e6a05941\testassembly.pdb
and selecting ReSharper item form the drop down list on the output window in Visual Studio I see
PdbNavigator: Downloader: http://srv.symbolsource.org/pdb/Public/testassembly.pdb/bf5be5cd155e4400b9b18c0e1e6a05941/testassembly.pdb -> The remote server returned an error: (500) Internal Server Error.
--OK, it's MS symbol server
PdbNavigator: Downloader: http://myproget/symbols/dev/testassembly.pdb/bf5be5cd155e4400b9b18c0e1e6a05941/testassembly.pdb -> ok, 15.5 KB
-- OK, it's our ProGet server
PdbNavigator: Searching for 'TestAssembly.TestClass' type sources in C:\Users\me\AppData\Local\Temp\SymbolCache\TestAssembly.pdb\bf5be5cd155e4400b9b18c0e1e6a05941\TestAssembly.pdb
PdbNavigator: Downloader: http://myproget/source-files/dev/TestAssembly/1.0.0.10/TestClass.cs -> The remote server returned an error: (404) Not Found.
-- Here we come :(
PdbNavigator: No sources found in debugging information for 'TestAssembly.TestClass' in assembly 'TestAssembly, Version=1.0.0.10, Culture=neutral, PublicKeyToken=null'
In my symbolcache folder there is a subfolder with this path
C:\Users\me\AppData\Local\Temp\SymbolCache\src\source-files\dev\TestAssembly\1.0.0.10
but there's no source file instead.
Taking a look inside the pdb file and I've found
SRCSRV: ini ------------------------------------------------
VERSION=2
INDEXVERSION=2
VERCTRL=http
SRCSRV: variables ------------------------------------------
SRCSRVVERCTRL=http
PGSERVER=http://myproget/source-files
PGFEED=dev
PGPKGID=TestAssembly
PGPKGVER=1.0.0.10
HTTP_EXTRACT_TARGET=%pgserver%/%pgfeed%/%pgpkgid%/%pgpkgver%/%var2%
SRCSRVTRG=%http_extract_target%
SRCSRVCMD=
SRCSRV: source files ---------------------------------------
c:\buildagent\work\b5cfc05c815c43d9\testassembly\testclass.cs*TestClass.cs
SRCSRV: end ------------------------------------------------
So, my question is: how can I download correctly the source file from ProGet?
What's wrong in my scenario?
Thank you!
Fabrizio
From ProGet's perspective, a 404 is returned by the /source-files/* endpoint in any of the following cases:
the feed name (i.e. dev in your example) is not found
the feed is not a NuGet feed
the symbol server is not enabled for the feed
the package version is missing from the /source-files URL
the package version is not a valid NuGet version (1.0.0.10 looks OK)
the file itself (i.e. TestClass.cs in your example) is not found under the /src folder within the package
That being said, can you verify in the feed itself that those source files are present using the Files tab for version 1.0.0.10 of this package? I know if the normal, non-symbols package is pushed after the symbols one, it can overwrite it which effectively removes those files.

Team Foundation Server Build errors....NuGet?

Im having build errors after building my Visual Studio Core repository from Team Foundation Server. My build order is Get Sources -> NuGet Restore, Build Solution, Publish Artifact
NuGet restore points to my NuGet.config file.
Looking at the error, it seems to me that my NuGet files are not being compiled. My Nuget files are pointing to a location in my file system. I can compile and run my program on VS but i cant successfully build using TFS.
Example errors:
project.assets.json not found, run a nuget restore to generate this file.
- After looking, I found the file in the same location it said not found?
The type or name space "System" could not be found
- Im getting this error for all 8 NuGet packages????
The NuGet.config can't be pointing to your file system if you expect the restore to work on a machine other than yours. It has to be pointing to a location that the build server can access.
I'd recommend setting up a Package Management feed containing your packages.

Resources