Coder Social home page Coder Social logo

dotnet / sourcelink Goto Github PK

View Code? Open in Web Editor NEW
1.2K 239.0 118.0 2.73 MB

Source Link enables a great source debugging experience for your users, by adding source control metadata to your built assets

License: MIT License

Batchfile 0.11% Shell 12.41% PowerShell 17.27% C# 68.62% CMake 1.50% Dockerfile 0.09%

sourcelink's Introduction

Source Link

Source Link is a language- and source-control agnostic system for providing first-class source debugging experiences for binaries. The goal of the project is to enable anyone building NuGet libraries to provide source debugging for their users with almost no effort. Microsoft libraries, such as .NET Core and Roslyn have enabled Source Link. Source Link is supported by Microsoft.

Source Link specification describes source control metadata that can be embedded in symbols, binaries and packages to link them to their original sources.

Visual Studio 15.3+ supports reading Source Link information from symbols while debugging. It downloads and displays the appropriate commit-specific source for users, such as from raw.githubusercontent, enabling breakpoints and all other sources debugging experience on arbitrary NuGet dependencies. Visual Studio 15.7+ supports downloading source files from private GitHub and Azure DevOps (former VSTS) repositories that require authentication.

The original Source Link implementation was provided by @ctaggart. Thanks! The .NET Team and Cameron worked together to make this implementation available in the .NET Foundation.

If you arrived here from the original Source Link documentation - you do not need to use SourceLink.Create.CommandLine.

Using Source Link in .NET projects

Starting with .NET 8, Source Link for the following source control providers is included in the .NET SDK and enabled by default:

If your project uses .NET SDK 8+ and is hosted by the above providers it does not need to reference any Source Link packages or set any build properties.

Otherwise, you can enable Source Link experience in your project by setting a few properties and adding a PackageReference to a Source Link package specific to the provider:

<Project>
 <PropertyGroup>
    <!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
    <PublishRepositoryUrl>true</PublishRepositoryUrl>
 
    <!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
    <EmbedUntrackedSources>true</EmbedUntrackedSources>
  </PropertyGroup>
  <ItemGroup>
    <!-- Add PackageReference specific for your source control provider (see below) --> 
  </ItemGroup>
</Project>

Source Link packages are currently available for the source control providers listed below.

Source Link package is a development dependency, which means it is only used during build. It is therefore recommended to set PrivateAssets to all on the package reference. This prevents consuming projects of your nuget package from attempting to install Source Link.

Referencing any Source Link package in a .NET SDK 8+ project suppresses Source Link that is included in the SDK.

github.com and GitHub Enterprise

For projects hosted by GitHub or GitHub Enterprise reference Microsoft.SourceLink.GitHub like so:

<ItemGroup>
  <PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>

Azure Repos (former Visual Studio Team Services)

For projects hosted by Azure Repos in git repositories reference Microsoft.SourceLink.AzureRepos.Git:

<ItemGroup>
  <PackageReference Include="Microsoft.SourceLink.AzureRepos.Git" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>

Azure DevOps Server (former Team Foundation Server)

For projects hosted by on-prem Azure DevOps Server in git repositories reference Microsoft.SourceLink.AzureDevOpsServer.Git and add host configuration like so:

<ItemGroup>
  <PackageReference Include="Microsoft.SourceLink.AzureDevOpsServer.Git" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>

You also need to provide the hostname of your DevOps server:

<ItemGroup>
  <SourceLinkAzureDevOpsServerGitHost Include="server-name"/>
</ItemGroup>

The Include attribute specifies the domain and optionally the port of the server (e.g. server-name or server-name:8080).

If your server is configured with a non-empty IIS virtual directory, specify this directory like so:

<ItemGroup>
  <SourceLinkAzureDevOpsServerGitHost Include="server-name" VirtualDirectory="tfs"/>
</ItemGroup>

GitLab

For projects hosted by GitLab reference Microsoft.SourceLink.GitLab package:

<ItemGroup>
  <PackageReference Include="Microsoft.SourceLink.GitLab" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>

Starting with version 8.0.0, Microsoft.SourceLink.GitLab assumes GitLab version 12.0+ by default. If your project is hosted by GitLab older than version 12.0 you must specify SourceLinkGitLabHost item group in addition to the package reference:

<ItemGroup>
  <SourceLinkGitLabHost Include="gitlab.yourdomain.com" Version="11.0"/>
</ItemGroup>

The item group SourceLinkGitLabHost specifies the domain of the GitLab host and the version of GitLab. The version is important since URL format for accessing files changes with version 12.0. By default Source Link assumes new format (version 12.0+).

You might also consider using environment variable CI_SERVER_VERSION (Version="$(CI_SERVER_VERSION)") if available in your build environment.

Bitbucket

For projects in git repositories hosted on Bitbucket.org or hosted on an on-prem Bitbucket server reference Microsoft.SourceLink.Bitbucket.Git package:

<ItemGroup>
  <PackageReference Include="Microsoft.SourceLink.Bitbucket.Git" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>

If your project is hosted by Bitbucket Server or Bitbucket Data Center older than version 4.7 you must specify SourceLinkBitbucketGitHost item group in addition to the package reference:

<ItemGroup>
  <SourceLinkBitbucketGitHost Include="bitbucket.yourdomain.com" Version="4.5"/>
</ItemGroup>

The item group SourceLinkBitbucketGitHost specifies the domain of the Bitbucket host and the version of Bitbucket. The version is important since URL format for accessing files changes with version 4.7. By default Source Link assumes new format (version 4.7+).

gitweb

For projects hosted on-prem via gitweb reference Microsoft.SourceLink.GitWeb package:

<ItemGroup>
  <PackageReference Include="Microsoft.SourceLink.GitWeb" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>

gitea

For projects hosted on-prem via gitea reference Microsoft.SourceLink.Gitea package:

<ItemGroup>
  <PackageReference Include="Microsoft.SourceLink.Gitea" Version="8.0.0" PrivateAssets="All"/>
</ItemGroup>

Multiple providers, repositories with submodules

If your repository contains submodules hosted by multiple git providers reference packages of all these providers, unless the project uses .NET SDK 8+ and submodules only use providers for which Source Link support is included. For example, projects in a repository hosted by Azure Repos that links a GitHub repository via a submodule should reference both Microsoft.SourceLink.AzureRepos.Git and Microsoft.SourceLink.GitHub packages. Additional configuration might be needed if multiple Source Link packages are used in the project.

Using Source Link in C++ projects

Source Link package supports integration with VC++ projects (vcxproj) and VC++ linker.

To add Source Link support to your native project add package references corresponding to your source control provider to packages.config directly or using NuGet Package Manager UI in Visual Studio. For example, the packages.config file for a project hosted on GitHub would include the following lines:

<packages>
  <package id="Microsoft.Build.Tasks.Git" version="8.0.0" targetFramework="native" developmentDependency="true" />
  <package id="Microsoft.SourceLink.Common" version="8.0.0" targetFramework="native" developmentDependency="true" />
  <package id="Microsoft.SourceLink.GitHub" version="8.0.0" targetFramework="native" developmentDependency="true" />
</packages>

Once the packages are restored and the project built the Source Link information is passed to the linker and embedded into the generated PDB.

The only feature currently supported is mapping of source files to the source repository that is used by the debugger to find source files when stepping into the code. Source embedding and embedding commit SHA and repository URL information in the native binary are not supported for native projects.

Prerequisites for .NET projects

Source Link supports classic .NET Framework projects as well as .NET SDK projects, that is projects that import Microsoft.NET.Sdk (e.g. like so: <Project Sdk="Microsoft.NET.Sdk">). The project may target any .NET Framework or .NET Core App/Standard version. All PDB formats are supported: Portable, Embedded and Windows PDBs.

.NET Core SDK 2.1.300 or newer is required for .NET SDK projects. If building via desktop msbuild you'll need version 15.7 or higher.

The following features are not available in projects that do not import Microsoft.NET.Sdk:

  • Automatic inclusion of commit SHA in AssemblyInformationalVersionAttribute.
  • Automatic inclusion of commit SHA and repository URL in NuSpec.

These features can be added via custom msbuild targets.

Prerequisites for C++ projects

Debugging native binary with Source Link information embedded in the PDB is supported since Visual Studio 2017 Update 9.

The VC++ linker supports /SOURCELINK switch since Visual Studio 2017 Update 8, however the PDBs produced by this version are not compatible with case-sensitive source control systems such as git. This issue is fixed in Visual Studio 2019.

Known issues

  • EmbedUntrackedSources does not work in Visual Basic projects that use .NET SDK: #193 (fixed in Visual Studio 2019)
  • Issue when building WPF projects with /p:ContinuousIntegrationBuild=true: #91
  • Issue when building WPF projects with embedding sources on and BaseIntermediateOutputPath not a subdirectory of the project directory: #492

PDB distributions

If you distribute the library via a package published to NuGet.org, it is recommended to build a symbol package and publish it to NuGet.org as well. This will make the symbols available on NuGet.org symbol server, where the debugger can download it from when needed.

Alternatively, Portable PDBs can be included in the main NuGet package by setting the following property in your project:

  <PropertyGroup>
    <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
  </PropertyGroup>  

Keep in mind that including PDBs in the .nupkg increases the size of the package and thus restore time for projects that consume your package, regardless of whether the user needs to debug through the source code of your library or not.

.snupkg symbol packages have following limitations:

  • They do not support Windows PDBs (generated by VC++, or for managed projects that set build property DebugType to full)
  • They require the library to be built by newer C#/VB compiler (Visual Studio 2017 Update 9).
  • The consumer of the package also needs Visual Studio 2017 Update 9 debugger.
  • Not supported by Azure DevOps Artifacts service.

Consider including PDBs in the main package if it is not possible to use .snupkg for the above reasons. For managed projects, consider switching to Portable PDBs by setting DebugType property to portable. This is the default for .NET SDK projects, but not classic .NET projects.

Builds

Pre-release builds are available from Azure DevOps public feed: https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json (browse).

Build Status

Experience in Visual Studio

The following screenshot demonstrates debugging a NuGet package referenced by an application, with source automatically downloaded from GitHub and used by Visual Studio 2017.

sourcelink-example

sourcelink's People

Contributors

0xced avatar adamralph avatar akoeplinger avatar alexperovich avatar austinwise avatar bruno-garcia avatar chuckries avatar clairernovotny avatar crummel avatar ctaggart avatar dagood avatar dotnet-bot avatar dotnet-maestro[bot] avatar dseefeld avatar ellahathaway avatar flcdrg avatar glen-nicol-garmin avatar johntortugo avatar jonfortescue avatar mmitche avatar nikolamilosavljevic avatar oleksandr-didyk avatar p10tyr avatar richlander avatar sridhar-ms avatar terrajobst avatar tmat avatar v-chayan avatar v-zbsail avatar viktorhofer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sourcelink's Issues

Display error or warning if GitHub remote is misconfigured

I tried out source link with code hosted on GitHub, but the url for the remote was misconfigured like this (note the www and the double slash in the url):

https://www.github.com//USERNAME/REPOSITORY

This made SourceLink embed an invalid url into the pdb:
https://USERNAME//REPOSITORY/COMMITHASH/*

Of course the error was the misconfigured remote url, but it would be great if SourceLink could produce an error or a warning is such cases.

Sourcelink doesn't work with inhouse TFS url's

I used the following configuration
<SourceRoot Include="sourcelink/" RepositoryUrl="http://tfs.mydomain.local:8080/tfs/DefaultCollection/TEAM/_git/MyProject" />

and I got this error
*\microsoft.sourcelink.common\1.0.0-beta-62925-02\build\Microsoft.SourceLink.Common.targets(60,5): error : SourceRoot.SourceLinkUrl is empty:

After trying a lots of different inputs and looking at the code I found that the issue is in file
SourceLink.Vsts.Git/GetSourceLinkUrl.cs at line 187 commit 4e067b1

The code fails when the /tfs/ part is in the url http://tfs.mydomain.local:8080/tfs/DefaultCollection/TEAM/_git/MyProject

var parts = localPath.Split('/');

if (parts.Length < 3 || parts.Length > 4)
{
     false;
}

There are 5 parts but it expects 3 or 4.

Microsoft.SourceLink.Vsts.Git does not add the sourcelink JSON

To get it to work I had to manually add a package reference to Microsoft.Build.Tasks.SourceControl. Once that was added it worked.

Comparing to the Github package the difference is that the nuspec for the Github package directly references Microsoft.Build.Tasks.SourceControl as a dependancy, while the VSTS Git/Tfs does not.

Build Fails on Linux

I get the following error:

/home/travis/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: The "Microsoft.Build.Tasks.Git.LocateRepository" task failed unexpectedly. [/home/travis/build/Dotnet-Boxed/Framework/Source/Boxed.Mapping/Boxed.Mapping.csproj]
/home/travis/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'git2-6311e88': The specified module or one of its dependencies could not be found. [/home/travis/build/Dotnet-Boxed/Framework/Source/Boxed.Mapping/Boxed.Mapping.csproj]

You can see the full build log here and the code here.

Sourcelink doesn't work on Fedora 27

Working with the dotnetsay sample on F27 and hit the following-

$dotnet pack -c release -o nupkg
Microsoft (R) Build Engine version 15.7.177.53362 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
 
  Restoring packages for /media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj...
  Installing Microsoft.Build.Tasks.Git 1.0.0-beta-62909-01.
  Installing Microsoft.SourceLink.Common 1.0.0-beta-62909-01.
  Installing Microsoft.SourceLink.GitHub 1.0.0-beta-62909-01.
  Generating MSBuild file /media/psf/Home/github/core/samples/dotnetsay/obj/dotnetsay.csproj.nuget.g.props.
  Generating MSBuild file /media/psf/Home/github/core/samples/dotnetsay/obj/dotnetsay.csproj.nuget.g.targets.
  Restore completed in 9.12 sec for /media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj.
  You are working with a preview version of the .NET Core SDK. You can define the SDK version via a global.json file in the current project. More at https://go.microsoft.com/fwlink/?linkid=869452
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: The "Microsoft.Build.Tasks.Git.LocateRepository" task failed unexpectedly. [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'git2-6311e88' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libgit2-6311e88: cannot open shared object file: No such file or directory [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary() [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods..cctor() [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    --- End of inner exception stack trace --- [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_buf_free(GitBuf buf) [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Repository.Discover(String startingPath) [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.LocateRepository.Execute() in /_/src/Microsoft.Build.Tasks.Git/LocateRepository.cs:line 19 [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]
/home/leecow/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/media/psf/Home/github/core/samples/dotnetsay/dotnetsay.csproj]

SourceLink doesn't work well with WPF projects

Error

Microsoft.Managed.Core.targets(90,5): SourceRoot items must include at least one top-level (not nested) item when DeterministicSourcePaths is true [C:\Temp\WpfApp1\WpfApp1\WpfApp1_3qoc4wf0_wpftmp.csproj]

is reported when building with /p:ContinuousIntegrationBuild=true.

Due to NuGet/Home#5894 - WPF projects do not import .props and .targets files from NuGet packages.

The "Microsoft.Build.Tasks.Git.LocateRepository" task failed unexpectedly.

When adding SourceLink to my project I get the following error.
I am using VSTS.
My environment is listed below,
Any help would be appreciated.

ฮป  dotnet build .\AppCenter.Core.csproj
Microsoft (R) Build Engine version 15.6.82.30579 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 32,51 ms for C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj.
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: The "Microsoft.Build.Tasks.Git.LocateRepository" task failed unexpectedly. [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.DotNet.PlatformAbstractions, Version=2.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified. [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.RuntimeIdMap.GetNativeLibraryDirectoryName() [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.GitLoaderContext.GetNativeLibraryDirectory() in /_/src/Microsoft.Build.Tasks.Git/GitLoaderContext.cs:line 55 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.GitLoaderContext.LoadUnmanagedDll(String unmanagedDllName) in /_/src/Microsoft.Build.Tasks.Git/GitLoaderContext.cs:line 30 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at System.Runtime.Loader.AssemblyLoadContext.ResolveUnmanagedDll(String unmanagedDllName, IntPtr gchManagedAssemblyLoadContext) [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary() [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods..cctor() [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    --- End of inner exception stack trace --- [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_buf_free(GitBuf buf) [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Repository.Discover(String startingPath) [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.RepositoryTasks.LocateRepository(LocateRepository task) in /_/src/Microsoft.Build.Tasks.Git.Operations/RepositoryTasks.cs:line 50 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.LocateRepository.Execute() in /_/src/Microsoft.Build.Tasks.Git/LocateRepository.cs:line 32 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() in E:\A\_work\82\s\src\Build\BackEnd\TaskExecutionHost\TaskExecutionHost.cs:line 631 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]
C:\Users\pshro\.nuget\packages\microsoft.build.tasks.git\1.0.0-beta-63102-01\build\Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() in E:\A\_work\82\s\src\Build\BackEnd\Components\RequestBuilder\TaskBuilder.cs:line 787 [C:\src\appcenter\lib-dotnet-appcenter\src\lib\AppCenter.Core\AppCenter.Core.csproj]

I have this .csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup Label="Description">
    <Title>Visual Studio App Center Core</Title>
    <PackageId>AppCenter.Core</PackageId>
    <Description>Visual Studio App Center features that depend upon only .NET Framework, System Interactive, System Reactive, TPL Dataflow, Immutable Collections, Microsoft Extensions, RecyclableMemoryStream, ValueTuple and JetBrains.Annotations</Description>
    <RootNamespace>AppCenter</RootNamespace>
    <TargetFrameworks>netstandard2.0</TargetFrameworks>
  </PropertyGroup>

  <PropertyGroup Label="Packaging">
    <AssemblyName>$(PackageId)</AssemblyName>
    <Authors>Microsoft</Authors>
    <Company>Microsoft Corporation</Company>
    <Copyright>Copyright ยฉ Microsoft Corporation. All rights reserved.</Copyright>
    <IsPackable>true</IsPackable>
    <PackageProjectUrl>https://www.visualstudio.com/app-center/</PackageProjectUrl>
    <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
    <PackageTags>Core;AppCenter</PackageTags>
    <Product>Visual Studio App Center</Product>
    <RepositoryType>git</RepositoryType>
    <RepositoryUrl>https://msmobilecenter.visualstudio.com/Mobile-Center/_git/appcenter</RepositoryUrl>
  </PropertyGroup>

  <PropertyGroup Label="Build">
    <DefineConstants>$(DefineConstants);CODE_ANALYSIS;JETBRAINS_ANNOTATIONS</DefineConstants>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
    <IsTool>False</IsTool>
    <LangVersion>latest</LangVersion>
    <NeutralLanguage>en</NeutralLanguage>
    <OutputType>Library</OutputType>
    <PlatformTarget>x64</PlatformTarget>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)'=='Release'">
    <DefineConstants>TRACE</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)'=='Debug'">
    <DefineConstants>TRACE;DEBUG</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Label="Sign">
    <SignAssembly>False</SignAssembly>
    <AssemblyOriginatorKeyFile>..\..\..\tools\build-dotnet\signing\AppCenter.snk</AssemblyOriginatorKeyFile>
  </PropertyGroup>

  <PropertyGroup Label="SourceLink Settings">
    <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
    <DebugSymbols>True</DebugSymbols>
    <DebugType>Portable</DebugType>
    <EmbedUntrackedSources>true</EmbedUntrackedSources>
    <IncludeSource>True</IncludeSource>
    <IncludeSymbols>True</IncludeSymbols>
    <PublishRepositoryUrl>true</PublishRepositoryUrl>
  </PropertyGroup>

  <ItemGroup Label="SourceLink Packages">
    <PackageReference Include="Microsoft.SourceLink.Vsts.Git" Version="1.0.0-beta-63102-01" PrivateAssets="all" />
  </ItemGroup>
<!-- 
  <ItemGroup Label="Versioning">
    <PackageReference Include="Nerdbank.GitVersioning" Version="2.1.23" PrivateAssets="all" />
  </ItemGroup>
 -->
  <PropertyGroup Condition="'$(Configuration)'=='Release'">
    <DocumentationFile>bin\Release\netstandard2.0\AppCenter.Core.xml</DocumentationFile>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)'=='Debug'">
    <DocumentationFile>bin\Debug\netstandard2.0\AppCenter.Core.xml</DocumentationFile>
  </PropertyGroup>

  <ItemGroup Label="Package References">
    <PackageReference Include="Castle.Core" Version="4.3.1" />
    <PackageReference Include="FluentAssertions" Version="5.4.1" />
    <PackageReference Include="Humanizer.Core" Version="2.4.2" />
    <PackageReference Include="JetBrains.Annotations" Version="11.1.0" />
    <PackageReference Include="LanguageExt.Core" Version="3.0.18" />
    <PackageReference Include="Microsoft.Extensions.ObjectPool" Version="2.1.1" />
    <PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.2.2" />
    <PackageReference Include="Serilog" Version="2.7.1" />
    <PackageReference Include="System.Collections.Immutable" Version="1.5.0" />
    <PackageReference Include="System.Interactive" Version="3.1.1" />
    <PackageReference Include="System.Interactive.Async" Version="3.1.1" />
    <PackageReference Include="System.Interactive.Async.Providers" Version="3.1.1" />
    <PackageReference Include="System.Interactive.Providers" Version="3.1.1" />
    <PackageReference Include="System.Reactive" Version="4.0.0" />
    <PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.9.0" />
    <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.1" />
    <PackageReference Include="System.ValueTuple" Version="4.5.0" />
  </ItemGroup>

</Project>

My dotnet environment is:

ฮป  dotnet --info
.NET Command Line Tools (2.1.101)

Product Information:
 Version:            2.1.101
 Commit SHA-1 hash:  6c22303bf0

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.101\

Host (useful for support):
  Version: 2.1.1
  Commit:  6985b9f684

.NET Core SDKs installed:
  1.0.3 [C:\Program Files\dotnet\sdk]
  1.0.4 [C:\Program Files\dotnet\sdk]
  1.1.0 [C:\Program Files\dotnet\sdk]
  2.0.0-preview2-006497 [C:\Program Files\dotnet\sdk]
  2.0.0 [C:\Program Files\dotnet\sdk]
  2.0.2 [C:\Program Files\dotnet\sdk]
  2.0.3 [C:\Program Files\dotnet\sdk]
  2.1.2 [C:\Program Files\dotnet\sdk]
  2.1.3 [C:\Program Files\dotnet\sdk]
  2.1.4 [C:\Program Files\dotnet\sdk]
  2.1.101 [C:\Program Files\dotnet\sdk]
  2.1.102 [C:\Program Files\dotnet\sdk]
  2.1.103 [C:\Program Files\dotnet\sdk]
  2.1.104 [C:\Program Files\dotnet\sdk]
  2.1.105 [C:\Program Files\dotnet\sdk]
  2.1.200 [C:\Program Files\dotnet\sdk]
  2.1.201 [C:\Program Files\dotnet\sdk]
  2.1.300 [C:\Program Files\dotnet\sdk]
  2.1.301 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0-preview2-25407-01 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

VSTS SSH Git Remote does not work?

I'm getting the following error:

C:\Users\joschm\.nuget\packages\microsoft.sourcelink.common\1.0.0-beta-62909-01\build\Microsoft.SourceLink.Common.targets(59,5): error : SourceRoot.SourceLinkUrl is empty: 'C:\Users\joschm\Intentional\services-utilities\' [C:\Users\joschm\Intentional\services-utilities\Authentication\Authentication.csproj]

I'm guessing it's because I use ssh as my Git remote.

ฮป git remote -v
origin  ssh://[email protected]:22/intent/_ssh/services-utilities (fetch)
origin  ssh://[email protected]:22/intent/_ssh/services-utilities (push)

Is this not supported yet?

Add task that generates .props file with SourceLink info for a source package

To provide SourceLink information for a source package to the project that references such package one can write a task that generates .props file below and include it in the build directory of the source package (the below example is from Microsoft.CodeAnalysis.PooledObjects package):

  <ItemGroup>
    <SourceRoot Include="$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\contentFiles\cs\$(TargetFramework)\'))"
                SourceLinkUrl="https://raw.githubusercontent.com/dotnet/roslyn/3590c5574234ecac536c98d69d8a892e61feb4e3/src/Dependencies/PooledObjects/*"/>
  </ItemGroup>

The target in Roslyn repository that generates the above props is:

<Target Name="GenerateSourcePackagePropsFile"
          BeforeTargets="Build"
          Condition="'$(TargetFrameworks)' == '' or '$(IsCrossTargetingBuild)' == 'true'"
          Outputs="$(_SourcePackagePropsFilePath)">
    
    <PropertyGroup>
      <_RelativePath>$([MSBuild]::MakeRelative($(RepoRoot), $(MSBuildProjectDirectory)))</_RelativePath>
      
      <!-- TODO: Proper URL escaping -->
      <_RawUrl>$(RepositoryRawUrl)/$(GitHeadSha)/$(_RelativePath.Replace('\', '/'))/*</_RawUrl>
      
      <_Content>
        <![CDATA[<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <SourceRoot Include="%24([System.IO.Path]::GetFullPath('%24(MSBuildThisFileDirectory)..\contentFiles\cs\%24(TargetFramework)\'))"
                SourceLinkUrl="$(_RawUrl)"/>
  </ItemGroup>
</Project>]]>
      </_Content>
    </PropertyGroup>
    <MakeDir Directories="$(_SourcePackagePropsDirPath)" />
    <WriteLinesToFile File="$(_SourcePackagePropsFilePath)" Lines="$(_Content)" Overwrite="true" Encoding="UTF-8"/>
    <ItemGroup>
      <FileWrites Include="$(_SourcePackagePropsFilePath)" />
    </ItemGroup>
  </Target>

Generalize this target to a build task and expose it from Microsoft.SourceLink.Common package.

To complete the end-to-end scenario we would want to also have NuGet Pack support for source packages. Then we could integrate the above task into the build system automatically when Microsoft.SourceLink.* package is referenced.

STANDARD_CI_REPOSITORY_URL should trigger ContinuousIntegrationBuild=true

Following up from #114 (comment), the only way I can get my sourcelink json to be deterministic is if I set /p:ContinuousIntegrationBuild=true property myself in the CI scripts. The sourcelink json then looks like this:

{"documents":{"/_/*":"https://github.ecorp.test/raw/taggac/vsphere-automation-sdk-.net/e154aefe03eec1377b9588da5f32a056e97d4805/*"}}

I'd really prefer not having to set that manually. It looks like Microsoft.Build.StandardCI.props does what I want:

<ContinuousIntegrationBuild Condition="'$(ContinuousIntegrationBuild)' == '' and '$(DesignTimeBuild)' != 'true' and '$(STANDARD_CI_REPOSITORY_URL)' != ''">true</ContinuousIntegrationBuild>

Is Microsoft.Build.StandardCI.props going to be included Microsoft.SourceLink.Common package?

TeamCity Repository doesn't have any commit - need to support object/info/alternates

I'm having trouble getting the latest beta to work from TeamCity ctaggart/SourceLink#359 . TeamCity is simply delegating to run the build from the official docker image. I'm create the standard CI environment variables.

I've set the Standard CI environment variables:

[1:11:50][Step 1/1] STANDARD_CI_REPOSITORY_TYPE: git
[21:11:50][Step 1/1] STANDARD_CI_REPOSITORY_URL: [email protected]:taggac/vsphere-automation-sdk-.net.git
[21:11:50][Step 1/1] STANDARD_CI_SOURCE_REVISION_ID: 2faeb58bbe59b000c517f7c19e53fc371b10324e
1:12:38][Step 1/1] /root/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-63105-01/build/Microsoft.Build.Tasks.Git.targets(36,5): warning : Repository doesn't have any commit, the source code won't be available via source link. [/build/VMware.vSphere.Management/VMware.vSphere.Management.csproj]
[21:12:38][Step 1/1] /root/.nuget/packages/microsoft.sourcelink.common/1.0.0-beta-63105-01/build/Microsoft.SourceLink.Common.targets(73,5): warning : No SourceRoot items specified - the generated source link is empty. [/build/VMware.vSphere.Management/VMware.vSphere.Management.csproj]
[21:14:43][Step 1/1]   VMware.vSphere.Management -> /build/VMware.vSphere.Management/bin/release/netstandard2.0/VMware.vSphere.Management.dll

The sourcelink json ends up being {"documents":{}}, so it did not work.

SourceRoot error with SourceLinkVstsGitDomain

I'm getting build warnings when building my project in VSTS against Git. The warning is:

C:\Users\VssAdministrator.nuget\packages\microsoft.sourcelink.common\1.0.0-beta-62925-02\build\Microsoft.SourceLink.Common.targets (60, 5)
C:\Users\VssAdministrator.nuget\packages\microsoft.sourcelink.common\1.0.0-beta-62925-02\build\Microsoft.SourceLink.Common.targets(60,5): Warning : No SourceRoot items specified - the generated source link is empty.

I added the Microsoft.SourceLink.Vsts.Git package to my project and set the SourceLinkVstsGitDomain to my company's root VSTS URL.

Source linking appears to be working correctly. I blew away my local project source, added the NuGet package to a test solution and I got prompted for the download of the source and could then step through the code. Beyond the warning everything seems to be working correctly. How do I get rid of this warning? Can the docs be updated to reflect the steps involved because right now I cannot find any that specify how to do it correctly. I figured it out from trial and error. Most are referencing the legacy SourceLink packages and/or settings up symbol server stuff.

Build fails after including a library built with SourceLink

I have a .NET Framework 4.7 project with a NuGet package reference of a .NET Standard 2.0 library I built with SourceLink.
The build fails with:

C:\mysolution\packages\Microsoft.Build.Tasks.Git.1.0.0-beta-62925-02\build\Microsoft.Build.Tasks.Git.targets(20,5): error : Unable to locate repository containing directory 'C:\mysolution\myproject'

This is due to the project I am trying to build not being under git source control.

To make this build I had to include the following in my project file:

<PropertyGroup>
    <RepositoryType>hg</RepositoryType>
</PropertyGroup>

This means that for anyone using my NuGet package, they would either need to be using git or make the manual change to their project file.

Here is where it defaults to git:

<PropertyGroup>
<RepositoryType Condition="'$(RepositoryType)' == ''">git</RepositoryType>
</PropertyGroup>

Source Link documentation example JSON

The documentation for Source Link JSON Schema is a little confusing to me, since I just started getting into Source Link. An example JSON file would be nice.

Use Case: I am trying to adapt the Source Link JSON generation for tfs 2013 and already constructed a working URL to use. The only thing that is really hard for me to figure out is how to create the custom JSON as some of the names of JSON properties are a little confusing. Especially the "documents" part that is later described in the minimal example. I can not figure out where to place the "documents" snippet explained in the "simplest Source Link JSON" in the full JSON.

Proposed Solution: Add a full example JSON e.g. for the CodeFormatter project.
If I simply had an example I could easily lookup where the "documents" part should go in the resulting JSON.

VSTS Git repo build in environment without Git installed

Hi,

I am working on onboarding sourcelink to our project and it is working properly when I build in my local machine.

However, when I build this project in buildreq system (which publishes our nuget package) and cloudbuild (which validates my pull request), it hits below error:

1>VerifyGitInstalled:
1> Verifying Git is installed
1> where /q git.exe
1> The command "where /q git.exe" exited with code 1.
1> Git is not installed.

d:\dbs\Cx\iri.cbt\microsoft.build.tasks.git\1.0.0-beta-62925-02\build\Microsoft.Build.Tasks.Git.targets(20,5): error : Unable to locate repository containing directory 'd:\dbs\sh\iri\0622_113742\cmd\3\src\libraries\microsoft.servicefabric.aspnetcore.configuration\source'.

And this error was due to Git not installed in buildreq and cloudbuild image, I wonder how I can resolve this issue? I am thinking include git.exe in my project and have the targets 'know' the path of git. Do you think this might work or any other ways?

Any suggestion would be appreciated!

Build failed on Travis-CI: CS0016 could not write to output file

The issue happens during building .NET Standard class library project on Dockerized Ubuntu where SourceLink tries to create and write to (Project Name)/obj/(Release or Debug)/netstandard2.0/(Project Name).sourcelink.json file. The error message is:

CSC : error CS0016: Could not write to output file '(Project Name)/obj/(Release or Debug)/netstandard2.0/(Project Name).sourcelink.json file' -- 'Could not find file '(Project Name)/obj/(Release or Debug)/netstandard2.0/(Project Name).sourcelink.json'.'

See full build log for detail. Full project file can be found here.

To date, the issue is not observed on other platforms such as Windows and Mac OS.

Linking NuGets with souce code included

This might be either uninformed, or out of scope of what you are trying to do, so feel free to close immediately.

I noticed that dotnet pack has --include-source option. I then spent some time trying to find out how to use such source code inclussion for debugging... and the only thing I have found is your project. You, as far as I can see, do not allow to take the source (for, let's say, MyOrg.MyLib 1.2.3) from another NuGet (MyOrg.MyLib.symbols 1.2.3). You just ask network locations file-by-file.

Now I wonder whether generic NuGet source code provider could be done for SourceLink. It would solve problems with attempting to support every authentication scheme every repo browser has on a case-by-case basis -- it would be NuGet's issue now to handle obtaining the symbol nuget based on local package source settings. And it would have a chance to work offline thanks to local NuGet caches.

SourceLink fails on macOS Mojave with "PlatformNotSupportedException: osx.10.14-x64"

Repro

Create the sample in the README of this repo and dotnet build

Error

/Users/nmcmaster/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-63102-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: The "Microsoft.Build.Tasks.Git.LocateRepository" task failed unexpectedly. [/Users/nmcmaster/dev/natemcmaster/dotnet-serve/src/dotnet-serve/dotnet-serve.csproj]
/Users/nmcmaster/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-63102-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.PlatformNotSupportedException: osx.10.14-x64 [/Users/nmcmaster/dev/natemcmaster/dotnet-serve/src/dotnet-serve/dotnet-serve.csproj]
/Users/nmcmaster/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-63102-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.RuntimeIdMap.GetNativeLibraryDirectoryName() in /_/src/Microsoft.Build.Tasks.Git/RuntimeIdMap.cs:line 22 [/Users/nmcmaster/dev/natemcmaster/dotnet-serve/src/dotnet-serve/dotnet-serve.csproj]

Details

Using: 1.0.0-beta-63102-01

Integration tests

  • test nested submodules
  • test cross provider submodules (VSTS, GitHub)
  • test error reported when multiple source control packages are referenced

...

TFS git repository configuration

How do we configure this for git repos that live in TFS? According to this issue - #39 - I added Microsoft.SourceLink.Vsts.Git and set <SourceLinkVstsGitDomain>mydomain:8080</SourceLinkVstsGitDomain>, but I get an error:

......nuget\packages\microsoft.sourcelink.common\1.0.0-beta-62925-02\build\Microsoft.SourceLink.Common.targets(60,5): error : SourceRoot.SourceLinkUrl is empty: 'C:\git\MyProjectName\'

Our git repo lives under http://mydomain:8080/tfs/MyCollection/_git/MyProjectName

Also, how do we specify https? It's weird that http is the default (according to code)

Build fails on macOS - DllNotFoundException error in LibGit2Sharp

Repo: https://github.com/steamre/steamkit/tree/2.1.0-Beta.1

CsProj file has:

  <ItemGroup>
    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta-62909-01" />
    ...
  </ItemGroup>

CI builds on Windows and Linux are passing.

When I try to build on macOS, I get this error:

[06:14pm yaakov@MacBook-Pro:~/Development/Projects/SteamKit] (branch: master) dotnet build SteamKit2/SteamKit2.sln
Microsoft (R) Build Engine version 15.7.177.53362 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 46.84 ms for /Users/yaakov/Development/Projects/SteamKit/Resources/SteamLanguageParser/SteamLanguageParser.csproj.
  Restore completed in 61.23 ms for /Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj.
  Restore completed in 61.88 ms for /Users/yaakov/Development/Projects/SteamKit/SteamKit2/Tests/Tests.csproj.
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: The "Microsoft.Build.Tasks.Git.LocateRepository" task failed unexpectedly. [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'git2-6311e88': The specified module or one of its dependencies could not be found. [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:  (Exception from HRESULT: 0x8007007E) [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary() [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods..cctor() [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    --- End of innerexception stack trace --- [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_buf_free(GitBuf buf) [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Repository.Discover(String startingPath) [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.LocateRepository.Execute() in /_/src/Microsoft.Build.Tasks.Git/LocateRepository.cs:line 19 [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
  SteamLanguageParser -> /Users/yaakov/Development/Projects/SteamKit/Resources/SteamLanguageParser/bin/Debug/netcoreapp2.0/SteamLanguageParser.dll

Build FAILED.

/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: The "Microsoft.Build.Tasks.Git.LocateRepository" task failed unexpectedly. [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018: System.TypeInitializationException: The type initializer for 'LibGit2Sharp.Core.NativeMethods' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'git2-6311e88': The specified module or one of its dependencies could not be found. [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:  (Exception from HRESULT: 0x8007007E) [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_libgit2_init() [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.InitializeNativeLibrary() [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods..cctor() [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    --- End of innerexception stack trace --- [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.NativeMethods.git_buf_free(GitBuf buf) [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Core.Proxy.ConvertPath(Func`2 pathRetriever) [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at LibGit2Sharp.Repository.Discover(String startingPath) [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.Tasks.Git.LocateRepository.Execute() in /_/src/Microsoft.Build.Tasks.Git/LocateRepository.cs:line 19 [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
/Users/yaakov/.nuget/packages/microsoft.build.tasks.git/1.0.0-beta-62909-01/build/Microsoft.Build.Tasks.Git.targets(20,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__25.MoveNext() [/Users/yaakov/Development/Projects/SteamKit/SteamKit2/SteamKit2/SteamKit2.csproj]
    0 Warning(s)
    1 Error(s)

Runtime information:

.NET Command Line Tools (2.1.200)

Product Information:
 Version:            2.1.200
 Commit SHA-1 hash:  2edba8d7f1

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.13-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.200/

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.7
  Build    : 2d61d0b043915bc948ebf98836fefe9ba942be11

Not download source code from VSTS Git repo

Can't get source code of my nuget package from vsts feed when debugging my application.

Use this configuration of sourcelink for Vsts.Git implementation:

 <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AssemblyName>Doctis.Common</AssemblyName>
    <PublishRepositoryUrl>true</PublishRepositoryUrl>
    <EmbedUntrackedSources>true</EmbedUntrackedSources
  
  <AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
  </PropertyGroup>

In pdb file from package I see some information about my repo:

{
    "documents": {
        "D:\\a\\1\\s\\*": "https://#####.visualstudio.com/Doctis/_apis/git/repositories/Doctis.Common/items?api-version=1.0&versionType=commit&version=ae3398cc9eef7adeb7d2b397c151a6d861175b3c&path=/*"
    }
}

When start debug I see in modules my package with symbols from package, but I can't step into my source code from nuget package.

Environment variables for URL mapping in VSTS

Draft specification:

BUILD_REPOSITORY_URL_MAP{n}

Specifies a map of URLs stored in the repository (or its source control metadata) to permanent URLs that can be embedded in the artifacts produced by the build. This map can be set by the build server when it determines that the repository may contain URLs that might change in future. The build infrastructure can then use this map to replace non-permanent URLs with permanent ones that are resilient to such changes.

For example, a git repository may contain a submodule created using a non-permanent URL of the target repository. The build in this repository is set up such that it includes the URL of the submodule in the symbol file, so that the debugger can find the source files copiled from the submodule on the source server that hosts the submodule sources. BUILD_REPOSITORY_URL_MAP makes it possible to set up permanent (forwarding) URLs that the build infrastructure can use when producing the symbol file instead of the original URL stored in the git metadata.

The value of BUILD_REPOSITORY_URL_MAP variable is a semicolon-delimited list of URLs. The number of items in the list shall be even. Every odd item is the original URL and every even item is the mapped URL. If there are multiple mappings with the same original URLs the mapped URL of the last one shall be used.

On some systems the length of an environment variable is limited. If the length of the map were to exceed this limit additional URLs can be specified in variables BUILD_REPOSITORY_URL_MAP1, BUILD_REPOSITORY_URL_MAP2, etc., each having the same syntax as BUILD_REPOSITORY_URL_MAP. When building the complete map a reader shall first check if variable BUILD_REPOSITORY_URL_MAP specifies is set. If so it shall add its mappings to the map. It shall then check if BUILD_REPOSITORY_URL_MAP1 is set. If so it shall add its mappings to the map. Et cetera. The construction of the map ends with the first n for which variable BUILD_REPOSITORY_URL_MAP{n} is not set.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.