This is something all projects will need OOB, so it's best
if we add it here.
Individual projects could re-set the properties to blank
values if desired, via their .csproj, with:
<PropertyGroup>
<StartAction />
<StartProgram />
<StartArguments />
</PropertyGroup>
In some scenarios, nuget generates the import lines in the wrong order,
causing the buildtools to malfunction because the right default variables
like $(Dev) do not have the expected values
This reverts commit 2dd816020d.
This approach doesn't work in the general case, since depending on whether
the project producing the VSIX has already built or not, the file does not
end up being copied to the referencing project.
The better way is to just add a `CopyVsix=true` metadata to the VSIX project
references we wish to copy to the output, and add a target like the following
to the referencing project:
<Target Name="PrepareVsixProjectReferences"
BeforeTargets="ResolveProjectReferences"
DependsOnTargets="PrepareProjectReferences">
<MSBuild
Projects="@(_MSBuildProjectReferenceExistent)"
Targets="CreateVsixContainer;VSIXContainerProjectOutputGroup"
BuildInParallel="$(BuildInParallel)"
Properties="%(_MSBuildProjectReferenceExistent.SetConfiguration); %(_MSBuildProjectReferenceExistent.SetPlatform); %(_MSBuildProjectReferenceExistent.SetTargetFramework); CreateVsixContainer=true"
Condition="'%(_MSBuildProjectReferenceExistent.CopyVsix)' == 'true'"
ContinueOnError="!$(BuildingProject)"
RemoveProperties="%(_MSBuildProjectReferenceExistent.GlobalPropertiesToRemove)">
<Output TaskParameter="TargetOutputs" ItemName="_ProjectReferenceVsixOutputs" />
</MSBuild>
<ItemGroup>
<None Include="@(_ProjectReferenceVsixOutputs)" Condition="Exists('%(Identity)')" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
</Target>
If a VSIX is produced at all, this allows referencing projects to get it
in their own output directory, which is useful for tests that might want
to make assertions about its contents or install it for integration
testing purposes.
Extensions should never reference a newer target framework than net46
in VS2017, as documented in https://github.com/github/VisualStudio/issues/1849#issuecomment-411570902.
Therefore, we redesigned the mapping so it's now:
| TargetFramework | Visual Studio |
|-------|------|
| net45 | 2013 |
| net452| 2015 |
| net46 | 2017 |
| net47 | 2019 |
Switch to using Microsoft.Build.Locator instead of hacking MSBuild to
force it to resolve properly. We now run the tests against the same
MSBuild that built the tests.
We don't necessarily need to generate the pkgdef unless
it will be used, which only happens if the `GetVsixSourceItems`
target runs. Running too eagerly might cause it to also run
before CoreBuild for example, as well as during XAML two-pass
compilation, when it's not necessary.
Turns out that the VsSDKVersion already provides what we were previously using
the tasks version for. Just in case we really need to know the tasks version,
keep that property in the new VsSDKTasksVersion property.
We were conditioning the generation of the pkgdef to a property that doesn't
exist anymore (the fusion expression). Also, if the `@(BindingRedirect)` is
populated more dynamically, statically calculating the property to detemrine
if generation should happen won't work.
So instead, just condition the main target `BindingRedirects` to the existence
of `@(BindingRedirect)` items at the time the target is about to be run.
This makes it more explicit and intuitive on what those values mean. The previous
property affected only the upper (to) limit of the redirected 'oldVersion', so the
new properties reflect that more effectively.
Also allowing to change the default lower bound is simpler for cases where you want
to default to something other than 0.0.0.0.
Usage examples:
```
<BindingRedirected Include="Newtonsoft.Json">
<!-- Showcases specifying only From metadata -->
<From>6.0.0.0</From>
</BindingRedirected>
<!-- Showcases specifying no From/To metadata at all -->
<BindingRedirected Include="AutoMapper" />
<!-- Showcases matching a specific assembly -->
<BindingRedirected Include="^System, Version=4.0.0.0" From="2.0.0.0" />
<!-- Showcases matching with a regex that matches two assemblies -->
<BindingRedirected Include="System.Xml.+" From="3.0.0.0" />
```
The only configurable property is:
```
<PropertyGroup>
<!-- Causes default old version from to be 99.9.9.9 -->
<BindingRedirectAllVersions>true</BindingRedirectAllVersions>
</PropertyGroup>
```
Pending some tests, but manual testing verified.