ctaggart / SourceLink

Source Code On Demand
MIT License
357 stars 55 forks source link

BitBucketServer soucrelink-git create fails (.NET Standard 2.0) #323

Closed HristoHentov closed 6 years ago

HristoHentov commented 6 years ago

I am to trying to get sourcelink to work with bitbucket server, however when I try to build my project with dotnet build /p:SourceLinkCreate=true /v:n.

The setup is as follows. My code resides on https://bitbucket.mycompany.com/projects/AA/repos/my.repo.full.name

I have added the SourceLink.Create.BitBucket.Server and have edited the .csproj to contain the following inforamtion:

<PropertyGroup>
 <SourceLinkUrl>https://bitbucket.mycompany.com/projects/AA/repos/my.repo.full.name</SourceLinkUrl>
    <DebugType>portable</DebugType>

</PropertyGroup>

The error I recieve is : C:\Users\hristo.h\.nuget\packages\sourcelink.create.bitbucketserver\2.8.0\build\SourceLink.Create.BitBucketServer.targets(25,5): error : exit code 1 when running: dotnet sourcelink-git create -u "https://bitbucket.mycompany.com/projects/AA/repos/my.repo.full.name" -f "obj\Debug\netstandard2.0\sourcelink.json" --notingit "embed" --hashmismatch "embed" [C:\Projects\TheRepoProject\my.repo.full.name\src\Folder.Some.Other.Folder\Namespace.Name.csproj]

Is there something else that needs to be added? I saw some previous issue that involved adding a placeholder for the commit in the url, but not sure how this is supposed to work

HristoHentov commented 6 years ago

Update: Before I Begin here is some meta info about my enviroment.

VisualStudio: 2017, version: 15.6.2 Targeting: .NET Standard 2.0 Remote repo host: Bitbucket (company domain)

Okay so I tired a clean setup with a test repo hosted behind our company bitbucket domain and a simple console app as a client and still failed.

I'll go over exactly what I do, and where it gets me going on :

  1. Create a new project. (Targeting .NET Standard 2.0)
  2. Add a class with some test methods. (Code that I can try to step into later)
  3. Install SourceLink.Create.BitBucketServer nugget.
  4. Push to our remote repo - the link is in the form of https://bitbucket.mycompany.com/projects/MK/repos/sourcelinktest/
  5. Our CI (Jenkins) then builds the nuget.
  6. I Install the nuget and try to step into the code that it exposes - nothing happens.

Running dotnet build /p:SourceLinkCreate=true /v:n on my project results in "unable to find repository origin with: dotnet sourcelink-git origin".

NOTE: Running with SouceLink.Create.CommandLine results in: "unable to convert OriginURL: https://my.username@bitbucket.company.com/scm/mk/sourcelinktest.git""

Adding <SourceLinkUrl>https://bitbucket.company.com/projects/mk/repos/sourcelinktest/raw/*?at={commit}</SourceLinkUrl>

to the csproj and running the same command results in:

exit code 1 when running: dotnet sourcelink-git create -u "https://bitbucket.company.com/projects/mk/repos/sourcelinktest/raw/*?at={commit}" -f "obj\Debug\netstandard2.0\sourcelink.json" --notingit "embed" --hashmismatch "embed"

I forked SourceLink and ran the dotnet sourcelink-git with the same command args. I first got an error about not being able to find the file at obj\Debug\netstandard2.0\sourcelink.json (which I fixed by creating the folders) I got a json that had the following mapping:

{"documents":{"C:\\Projects\\SourceLinkFork\\SourceLink\\*":"https://bitbucket.company.com/projects/mk/repos/sourcelinktest/raw/src/*?at=e7849dc03517032cb6e82b39c81a16141a308b64"}}

HristoHentov commented 6 years ago

Issue was resolved by making sure we add

<ItemGroup>
    <DotNetCliToolReference Include="dotnet-sourcelink" Version="2.8.0" />
</ItemGroup>

To the .csproj file for the nuget we wanted to build. Apparently, SourceLink.Create.CommandLine uses commands from dotnet-sourcelink that require the CLI tool

ctaggart commented 6 years ago

Apparently, SourceLink.Create.CommandLine uses commands from dotnet-sourcelink that require the CLI tool

Not it does not. But SourceLink.Create.BitBucketServer uses dotnet-sourcelink-git as documented at: https://github.com/ctaggart/SourceLink/wiki#dotnet-sourcelink-git