Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL for Bitbucket cloud #185

Closed
PhilipDaniels opened this issue Oct 1, 2018 · 9 comments
Closed

URL for Bitbucket cloud #185

PhilipDaniels opened this issue Oct 1, 2018 · 9 comments
Milestone

Comments

@PhilipDaniels
Copy link

Trying to get SourceLink working with our Bitbucket cloud hosted solution. Our urls are of the form

https://bitbucket.org/COMPANYNAME/REPONAME.git

At least, I can type that into a browser window, but it will redirect me to

https://bitbucket.org/COMPANYNAME/REPONAME/src/master/

Anyway, I have published a package but when I try to step into it in VS2017 15.8 nothing happens - no error message, no dialog, it just steps over the method call.

Is this URL format supported? I was reading #31 and it links to this bit of code https://github.com/ctaggart/SourceLink/blob/master/SourceLink.Create.CommandLine/BitBucketServerUrlConverter.cs which does not match our URLs.

I have the latest preview version of SourceLink for Bitbucket installed.

@tmat
Copy link
Member

tmat commented Oct 8, 2018

Is the PDB loaded for the module (you can see loaded PDBs in Debug > Windows > Modules)?

@PhilipDaniels
Copy link
Author

Just commenting to say this was at work and I haven't had chance to get round to recreating the test case (yet).

@PhilipDaniels
Copy link
Author

Thanks @tmat I didn't know about that window. I have made some progress. The PDB was not loaded. I have added

<DebugType>embedded</DebugType>

to my csproj file and they are now getting loaded. So onto the next issue, which is that VS cannot find the source files. I get some output like the following. VS is first looking for a file path on the build server (which doesn't work of course) and then tries SourceLink

Locating source for 'C:\build\FCM-BCM1-JOB1\MyProj\Dummy.cs'. (No checksum.)
The file 'C:\build\FCM-BCM1-JOB1\MyProj\Dummy.cs' does not exist.
Looking in script documents for 'C:\build\FCM-BCM1-JOB1\MyProj\Dummy.cs'...
Looking in the projects for 'C:\build\FCM-BCM1-JOB1\MyProj\Dummy.cs'.
The file was not found in a project.
Looking in directory 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\VC\Tools\MSVC\14.15.26726\include\'...
...
Looking for source using Source Link (file://nothing/\\nothing\/raw/222c37aefa3bdd3b40c1fd797f1260cfdb1fa3ac/MyProj/Dummy.cs)...
Source Link errors:
uriString
The file was not found with Source Link.
The debugger will ask the user to find the file: C:\build\FCM-BCM1-JOB1\MyProj\Dummy.cs.

We are building our own NuSpec files and packing them using NuGet.exe, but the repository URL in the file looks good to me (apart from the redirect problem I mentioned in the initial report):

<repository type="git" url="https://bitbucket.org/mycompanyname/myrepo.git" commit="randomgithashhere" />

@PhilipDaniels
Copy link
Author

PhilipDaniels commented Nov 1, 2018

Further update. I checked the json doc that is created by SourceLink, and it contains a URL of the form

https://bitbucket.org/MyCompany/MyProject/raw/28ebd306a7612e496c73ff142d132f92847b717d/*

I've tried adding a path to a cs file on the end of that URL in the browser and that does indeed get me the raw source code.

For Info: The Bitbucket URL format is documented here https://confluence.atlassian.com/bitbucket/hyperlinking-to-source-code-in-bitbucket-824476709.html so it looks correct. Here is the code that builds the link https://github.com/dotnet/sourcelink/blob/master/src/SourceLink.Bitbucket.Git/GetSourceLinkUrl.cs

@PhilipDaniels
Copy link
Author

I've tried many things now. Currently I have the following in the csproj file

  <DebugType>embedded</DebugType>
  <RepositoryUrl>https://bitbucket.org/mycompany/my-repo.git</RepositoryUrl>
  <RepositoryType>git</RepositoryType>

<PackageReference Include="Microsoft.SourceLink.Bitbucket.Git" Version="1.0.0-beta-63401-01" PrivateAssets="All" />

and in the nuspec file

<repository type="git" url="https://bitbucket.org/mycompany/my-repo.git" commit="$GitCommit$" />

The project is being built with

msbuild /p:Configuration=Release;CreatePackages=1;CreateSymbols=false /t:restore;build

(Here, CreateSymbols is just a flag that is passed onto our CI targets that ensures that the -Symbols option is not passed to NuGet.exe, it's not relevant to this discussion. Likewise, CreatePackages is a flag that causes our targets to invoke 'nuget.exe pack').

Checking the log on Bamboo, I can see this:

    build	01-Nov-2018 15:08:41	C:\Users\Bamboo\.nuget\packages\microsoft.sourcelink.common\1.0.0-beta-63401-01\build\Microsoft.SourceLink.Common.targets(53,5): warning : Source control information is not available - the generated source link is empty. [C:\build\FCM-BCM1-JOB1\MySolution\MyProject.csproj]

Which probably explains why it is not working. At this point I'm stuck.

@AlexandreRevel
Copy link

Encountering the same behaviour with 1.0.0-beta2-19351-01. Same configuration is working fine locally. On build machine, I have the warning :
C:\Users\ContainerAdministrator\.nuget\packages\microsoft.sourcelink.common\1.0.0-beta2-19351-01\build\Microsoft.SourceLink.Common.targets(50,5): warning : Source control information is not available - the generated source link is empty.

And here are the logs form diagnostic dotnet build

Using "Microsoft.SourceLink.Bitbucket.Git.GetSourceLinkUrl" task from assembly "C:\Users\ContainerAdministrator\.nuget\packages\microsoft.sourcelink.bitbucket.git\1.0.0-beta2-19351-01\build\..\tools\netcoreapp2.0\Microsoft.SourceLink.Bitbucket.Git.dll".
build	12-Jul-2019 07:14:30	                   Task "Microsoft.SourceLink.Bitbucket.Git.GetSourceLinkUrl" (TaskId:59)
build	12-Jul-2019 07:14:30	                     Task Parameter:RepositoryUrl=https://bitbucket.****.com/scm/****/***.git (TaskId:59)
build	12-Jul-2019 07:14:30	                     Task Parameter:SourceRoot=C:\SourceCode\
build	12-Jul-2019 07:14:30	                                     MappedPath=/_/
build	12-Jul-2019 07:14:30	                                     RepositoryUrl=file://nothing/
build	12-Jul-2019 07:14:30	                                     RevisionId=060867f7fa6d5*******2a
build	12-Jul-2019 07:14:30	                                     ScmRepositoryUrl=file://nothing/
build	12-Jul-2019 07:14:30	                                     SourceControl=git (TaskId:59)
build	12-Jul-2019 07:14:30	                     Task Parameter:
build	12-Jul-2019 07:14:30	                         Hosts=
build	12-Jul-2019 07:14:30	                             bitbucket.***.com
build	12-Jul-2019 07:14:30	                             bitbucket.org
build	12-Jul-2019 07:14:30	                                     EnterpriseEdition=false (TaskId:59)
build	12-Jul-2019 07:14:30	                     Task Parameter:IsSingleProvider=True (TaskId:59)
build	12-Jul-2019 07:14:30	                     Output Property: _SourceLinkUrlToUpdate=N/A (TaskId:59)
build	12-Jul-2019 07:14:30	                   Done executing task "Microsoft.SourceLink.Bitbucket.Git.GetSourceLinkUrl". (TaskId:59)

The generated .nuspec contains correct informations, but not the dll.

@AlexandreRevel
Copy link

I think I have found the problem. It is linked with bamboo build server, me and @PhilipDaniels are both using it.
Here are detailed git checkout done by bamboo :

12-Jul-2019 08:23:17 | Build ***- Master - feature-***** - Default Job #16 (******) started building on agent ****
-- | --
12-Jul-2019 08:23:17 | Remote agent on host **
12-Jul-2019 08:23:17 | Build working directory is C:\bamboo-home\xml-data\build-dir\***
12-Jul-2019 08:23:17 | Executing build Tcc2 - Master - feature-**** - Default Job #16 (***)
12-Jul-2019 08:23:17 | Starting task 'Checkout Default Repository' of type 'com.atlassian.bamboo.plugins.vcs:task.vcs.checkout'
12-Jul-2019 08:23:17 | Build always requires a clean checkout
12-Jul-2019 08:23:17 | Cleaning build directory 'C:\bamboo-home\xml-data\build-dir\******'
12-Jul-2019 08:23:17 | Checking out into C:\bamboo-home\xml-data\build-dir\******
12-Jul-2019 08:23:17 | Updating source code to revision: ***********
12-Jul-2019 08:23:17 | 'C:\Program Files\Git\bin\git.exe' version
12-Jul-2019 08:23:17 | 'C:\Program Files\Git\bin\git.exe' log -1 --encoding=UTF-8 --format=%H HEAD
12-Jul-2019 08:23:17 | Creating local git repository in 'C:\bamboo-home\xml-data\build-dir\******\.git'.
12-Jul-2019 08:23:17 | 'C:\Program Files\Git\bin\git.exe' init
12-Jul-2019 08:23:18 | Initialized empty Git repository in C:/bamboo-home/xml-data/build-dir/******/.git/
12-Jul-2019 08:23:18 | 'C:\Program Files\Git\bin\git.exe' remote add origin file://nothing
12-Jul-2019 08:23:18 | 'C:\Program Files\Git\bin\git.exe' ls-remote ssh://3f740b65-3dc5-4c93-bc2e-***@127.0.0.1:49819/******/*****.git
12-Jul-2019 08:23:18 | Fetching 'refs/heads/feature/*****' from 'ssh://git@bitbucket.******.com:7999/******/*****.git'.
12-Jul-2019 08:23:18 | 'C:\Program Files\Git\bin\git.exe' fetch ssh://3f740b65-3dc5-4c93-bc2e-****@127.0.0.1:49819/******/*****.git +refs/heads/feature/*******:refs/heads/feature/DDR-378-alarm-reception-with-xtend-is-not-functionnal --update-head-ok --progress --verbose
12-Jul-2019 08:23:18 | Warning: Permanently added '[127.0.0.1]:49819' (RSA) to the list of known hosts.

The problem lies here for me :

12-Jul-2019 08:23:18 | 'C:\Program Files\Git\bin\git.exe' remote add origin file://nothing

@AlexandreRevel
Copy link

Adding git remote set-url origin https://bitbucket.honeywell.com/scm/datarelay/tcc2.git after source code checkout seems to be enough to solve this problem

@tmat tmat added this to the future milestone Oct 8, 2019
@tmat
Copy link
Member

tmat commented Nov 4, 2019

We have made several improvements and fixes in BitBucket support. Please try the latest package (version 1.0.0-beta2-19554-01). Feel free to reopen this issue if you find any problems with the package.

@tmat tmat closed this as completed Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants