-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update eligible projects to new SDK format. #1761
Conversation
434565b
to
624b6c6
Compare
I've seen VS extension projects using the new project system in Microsoft repos, for example here: but haven't found any info or documentation on that. Maybe this is an experimental & undocumented feature? |
I appears the Maybe @jnm2 will have some tips for us. 😄 |
@jcansdale I think you can use PackageReference even without the new project file format, it should be orthogonal to that. |
In fact I thought this would be at least a 2-step transition with multiple PRs to make this huge change easier to review and take iteratively. |
Sorry to disappoint, but when I looked at the VSIX project, I didn't see any ROI in getting it working with the new SDK. It's possible Oren has something up his sleeve—I know he has WPF working on the new csproj SDK. /~https://github.com/onovotny/MSBuildSdkExtras#msbuildsdkextras |
I don't understand what the problem with WPF is? I just tried creating a new WPF project & changing the csproj and everything worked fine. The only problem is that So using that, now the csproj looks like: <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net46</TargetFramework>
<OutputType>WinExe</OutputType>
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Xaml" />
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<None Remove="**\*.xaml" />
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="**\*.xaml" Exclude="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
</Project> everything works perfectly and it is stable when adding/removing xaml files inside VS (it doesn't modify the project file to add duplicate items). for a library, the includes would be simplified to: <ItemGroup>
<None Remove="**\*.xaml" />
<Page Include="**\*.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Update="**\*.xaml.cs">
<DependentUpon>%(Filename)</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup> |
624b6c6
to
f58e177
Compare
WPF projects and VSSDK projects can't use the SDK format yet. In addition `GitHub.TeamFoundation.15` uses an alias on a nuget package which can't currently be done, so the `GitHub.TeamFoundation.X` projects haven't been converted.
5b691b1
to
3eeb718
Compare
Had to also remove the `<RootNamespace>` as it was causing the resources to get generated in the wrong place.
Also - Removed more unnecessary dependencies - Moved a couple of tests to the right project - Removed `GitHub.Primitives.UnitTests` as it was testing stuff in `GitHub.Exports`, so moved to `GitHub.Exports.UnitTests`
Directory.Build.Props
Outdated
<PropertyGroup> | ||
<Product>GitHub Extension for Visual Studio</Product> | ||
<Version>2.5.4.0</Version> | ||
<Copyright>Copyright © GitHub, Inc. 2014-2018</Copyright> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could maybe do something like this to future-proof... 😉
<CopyrightYear>$([System.DateTime]::Now.ToString("yyyy"))</CopyrightYear>
<Copyright>Copyright © GitHub, Inc. 2014-$(CopyrightYear)</Copyright>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused where this project gets its VS SDK references from.
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<Project Sdk="Microsoft.NET.Sdk"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused where this project gets its VS SDK references from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It gets them from GitHub.Exports.
Having them be PCL meant that we had to have both a PCL and .netfx version of Splat, which was causing problems with test runners because they would load the wrong version of the library at random.
@Neme12 yep, i've managed to get WPF projects working now. Thanks for the pointer - I'd tried something similar before but couldn't get it to work. Not sure what I was missing. |
src/common/xaml.props
Outdated
<DependentUpon>%(Filename)</DependentUpon> | ||
<SubType>Code</SubType> | ||
</Compile> | ||
<Page Include="**\*.xaml"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why I included <None Remove="**\*.xaml" />
before this in my example is that without that, when adding a new xaml control inside VS, it adds a new line here with <None Remove="AddedFile.xaml" />
But I have no idea how this behaves and what VS would do when this is in am imported project. Did you check that it works properly and doesn't modify the csproj?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yeah you're right, it does modify the .csproj...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is the associated issue: dotnet/project-system#3639
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think for the moment I'm going to revert the change for converting our WPF projects to the new csproj and try again when 15.8 is available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think this was a bug. They are included as None by default so VS tries to do its best to undo that and make sure they're only included as Page.
This reverts commit aeca53a.
Conflicts: test/Helpers/SplatModeDetectorSetUp.cs
They weren't getting included in the vsix.
@jcansdale Hey, here's an example of a new-style VSIX project by @sharwell: /~https://github.com/tunnelvisionlabs/JustMyCodeToggle/blob/master/Tvl.VisualStudio.JustMyCodeToggle/Tvl.VisualStudio.JustMyCodeToggle.csproj |
It's been amazing. In all seriousness, I wonder what the telemetry would report if it was a native and documented feature. |
@sharwell just got back to this and tried using MSBuild.Sdk.Extras but I'm still getting the:
added whenever I add a XAML/cs file combination, and they don't appear nested. |
Have you added |
@onovotny yeah, I have. Just pushed the commit with the change in. If you want to try it, try going to GitHub.UI and adding a WPF user control and saving the solution. |
@onovotny this seems to be fixed with MSBuild.Sdk.Extras 1.6.52 - thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good in general, I'm just wondering where the settings for code analysis are. The csproj point to a specific ruleset, but this new format doesn't seem to have that setting or any configuration to enable/disable and set warnings as errors. Given how many warnings are on CI, I'm guessing it's using the default ruleset for these?
@@ -17,7 +17,7 @@ | |||
|
|||
public class VSGitExtTests | |||
{ | |||
public class TheConstructor : TestBaseClass | |||
public class TheConstructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this inheritance changing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ummm... I can't remember. I'll put this back.
Yes it's using the default ruleset for now, and not enabling warnings as errors. The new analyser has a lot more checks that are very useful and that I don't want to disable (such as always using My reasoning was that we should fix these warnings and enable warnings as errors in a separate PR. |
Can't remember why this was removed.
Really no idea why I removed these...
Directory.Build.Props
Outdated
@@ -1,7 +1,7 @@ | |||
<Project> | |||
<PropertyGroup> | |||
<Product>GitHub Extension for Visual Studio</Product> | |||
<Version>2.5.5.0</Version> | |||
<Version>2.5.6.0</Version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need to manually version? There are better ways to do this :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh really? Please do elucidate! What would be a better way to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've always hated version stamping. I'd be interested in finding the least-hacky way! 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a project that matches this one very closely -- xUnit for Devices. It has a VSIX for its templates and auto-versions.
/~https://github.com/xunit/devices.xunit
Here are some key things:
- Uses Nerdbank.GitVersioning to get a version for each commit. That handles the csproj's.
- Build scripts update other xml assets to match: /~https://github.com/xunit/devices.xunit/blob/master/.vsts-shared.yml#L31-L36
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to work well and it's impressive how much the size of .csproj files have been reduced. I think if we delay merging this now, we'll have nasty merge issues further down the road. I'd say LGTM since we're at the beginning a of a dev cycle.
Now we're using VS2017 we can use the new simplified SDK-style .csproj format. This PR updates the projects that can be updated to this format. It also enables
Microsoft.CodeAnalysis.FxCopAnalyzers
on them, which is the successor to CodeAnalysis. I've not enabled warnings as errors yet though, because these analyzers find a fair few problems that will need to be fixed first.WPF projects and VSSDK projects can't use the SDK format yet. In addition
GitHub.TeamFoundation.15
uses an alias on a nuget package which can't currently be done, so theGitHub.TeamFoundation.X
projects haven't been converted.