microsoft / vs-threading

The Microsoft.VisualStudio.Threading is a xplat library that provides many threading and synchronization primitives used in Visual Studio and other applications.
Other
991 stars 147 forks source link

Problem with AdditionalFiles and TFS #629

Open hugoqribeiro opened 4 years ago

hugoqribeiro commented 4 years ago

I have a solution with multiple project that references a design-time package of our own making that imports Microsoft.VisualStudio.Threading.Analyzers via a props file, like this:

<ItemGroup>
  <PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.6.13" PrivateAssets="All" />
<ItemGroup>

Notice PrivateAssets.

Every time that I restore the packages on this solution, all the files in AdditionalFiles are added to source countrol (TFS) automatically:

vs-threading.LegacyThreadSwitchingMembers.txt
vs-threading.MainThreadAssertingMethods.txt
Etc.

This only happens for these files. Everything else in the package is not added to source control.

I even have a .nuget file in the solution like this (that works fine for all other packages and all the files in this package, except those files mentioned above):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <solution>
        <add key="disableSourceControlIntegration" value="true" />
    </solution>
</configuration>

Is there something wrong with the way you add those files to your nuspec? How can I work around this?

Thanks in advance.

AArnott commented 4 years ago

Do these additional files show up in Solution Explorer? What version of VS are you using?

hugoqribeiro commented 4 years ago

Sorry, I forgot to mention that: VS 16.5.4. No, none of the files show in solution explorer.

AArnott commented 4 years ago

Are you using packages.config?

hugoqribeiro commented 4 years ago

Well. I'll try to explain with more detail.

This happens in .NET Core projects. Plain. No packages.config.

Has I said, we reference a design-time package that we use to set analyzers and their respective rules. This package is added to projects like this:

<Project Sdk="Microsoft.NET.Sdk">
  (...)
  <ItemGroup>
    <PackageReference Include="Primavera.Hydrogen.DesignTime.Configuration" Version="2.0.0.29" PrivateAssets="All" />
  <ItemGroup>
  (...)
</Project>

This package is built like this (nuspec file):

<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
    (...)
    <files>
        <file src="Props\Primavera.Hydrogen.DesignTime.Configuration.Source.props" target="build\Primavera.Hydrogen.DesignTime.Configuration.props" />
        (...)
    </files>
</package>

And the props file is:

<Project>
    (...)
    <ItemGroup>
        (...)
        <PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="16.6.13" PrivateAssets="All" />
    </ItemGroup>
</Project>

Microsoft.VisualStudio.Threading.Analyzers is restored and works OK.

The problem is: if I restore the original package (Primavera.Hydrogen.DesignTime.Configuration) on any solution/project for the first time, the refered files are added to source control.

But only those files, which I find strange (remember the .nuget file mentioned above, used to prevent VS to add packages to source control).

hugoqribeiro commented 4 years ago

I correct myself. I just found that the files do show up on one of the solution projects (although all reference them).

That project SDK is Microsoft.NET.Sdk.Web. The others are: Microsoft.NET.Sdk.

AArnott commented 4 years ago

I'm wondering how the AdditionalFiles could possibly be added to source control when they are under %USERPROFILE%\.nuget\packages\Microsoft.VisualStudio.Threading.Analyzers\..., which your TFVC workspace undoubtedly does not include. Is something in your repo copying these files into your TFVC workspace?

hugoqribeiro commented 4 years ago

All packages are restored to a folder in the solution directory tree, as set in the nuget.config file that sits in the root of the solution:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <packageRestore>
        <add key="enabled" value="True" />
        <add key="automatic" value="True" />
    </packageRestore>
    <packageSources>
        <add key="Lithium" value="http://nuget.primaverabss.com:82/nuget/public-lithium-general" />
        <add key="NuGet" value="http://api.nuget.org/v3/index.json" protocolVersion="3" />
    </packageSources>
    <activePackageSource>
        <add key="All" value="(Aggregate source)" />
    </activePackageSource>
    <config>
        <add key="globalPackagesFolder" value=".\_packages" />
        <add key="dependencyVersion" value="HighestPatch" />
    </config>
</configuration>

The directory tree is like this:

- Server
| -- .nuget
| -- | nuget.config <- the config that disables packages on source control
| -- _packages
| -- | (...)
| (...)
| -- WebApi
| -- | (...)
| -- | WebApi.csproj <- one of the project that references the package indirectly
| ECCO.sln
| nuget.config <- the config above