Giter Club home page Giter Club logo

msbuildsdkextras's Introduction

MSBuild.Sdk.Extras

Summary

This package contains a few extra extensions to the SDK-style projects that are currently not available in Microsoft.NET.Sdk SDK. This feature is tracked in dotnet/sdk#491 and many of the scenarios are on the roadmap for .NET 6.

The primary goal of this project is to enable multi-targeting without you having to enter in tons of properties within your csproj, vbproj, fsproj, thus keeping it nice and clean.

See the blog post for more information.

Supported .NET Core SDK Versions

Important: 3.x of the Extras requires the .NET 5 SDK or later. The SDK can build previous targets, like netcoreapp3.1. The extras 2.x supports SDK 2.x and 3.x.

Advanced Scenarios

This package also enables advanced library scenarios, allowing you to create reference assemblies and per-RuntimeIdentifier targets.

Reference Assemblies

Reference Assemblies useful in a few scenarios. Please see my two blogs for more details.

Per-RuntimeIdentifier

In some cases involving native interop, it may be necessary to have different runtime versions. NuGet has supported this for a while if you use PackageReference by way of its runtimes folder in combination with a Reference Assembly. Creating and packing these were manual though.

See below for creating these using the Extras easily.

Package Name: MSBuild.Sdk.Extras

Stable: MSBuild.Sdk.Extras

CI Feed: MSBuild.Sdk.Extras package in MSBuildSdkExtras feed in Azure Artifacts https://pkgs.dev.azure.com/clairernovotny/GitBuilds/_packaging/MSBuildSdkExtras/nuget/v3/index.json

Getting started (VS 15.6+)

Visual Studio 2017 Update 6 (aka v15.6) includes support for SDK's resolved from NuGet, which is required for this to work. VS 2019 is recommended.

Using the SDK

  1. Create a new project

    • .NET Core console app or .NET Standard class library.
    • With your existing SDK-style project.
    • With the templates in the repo's TestProjects folder.
  2. Replace Microsoft.NET.Sdk with MSBuild.Sdk.Extras to the project's top-level Sdk attribute.

  3. You have to tell MSBuild that the Sdk should resolve from NuGet by

    • Adding a global.json containing the Sdk name and version.
    • Appending a version info to the Sdk attribute value.
  4. Then you can edit the TargetFramework to a different TFM, or you can rename TargetFramework to TargetFrameworks and specify multiple TFM's with a ; separator.

The final project should look like this:

<Project Sdk="MSBuild.Sdk.Extras">
  <PropertyGroup>
    <TargetFrameworks>net46;uap10.0.19041;tizen8.0</TargetFrameworks>
  </PropertyGroup>
</Project>

The .NET 5 SDK is the latest and has more support for desktop workloads. It's strongly recommended to use that SDK, even to build older targets. If you are using MsBuild.Sdk.Extras version 2 or above, use the .NET Core 3.1 SDK at a minimum. You can still target previous versions of .NET Core.

{
  "msbuild-sdks": {
    "MSBuild.Sdk.Extras": "3.0.22"
  }
}

Above the sdk section indicates use the .NET Core 3 preview to build, the msbuild-sdks indicates the NuGet package to include.

Then, all of your project files, from that directory forward, uses the version from the global.json file. This would be a preferred solution for all the projects in your solution.

Then again, you might want to override the version for just one project OR if you have only one project in your solution (without adding global.json), you can do so like this:

<Project Sdk="MSBuild.Sdk.Extras/3.0.22">
  <PropertyGroup>
    <TargetFrameworks>net46;uap10.0.19041;tizen8.0</TargetFrameworks>
  </PropertyGroup>
</Project>

That's it. You do not need to specify the UWP or Tizen meta-packages as they'll be automatically included. After that, you can use the Restore, Build, Pack targets to restore packages, build the project and create NuGet packages. E.g.: msbuild /t:Pack ...

Important to Note

  • It will only work with an IDE that uses the desktop msbuild (i.e. Visual Studio) and the target Platform SDKs which are not cross platform.
  • When using JetBrains Rider, you will need to point to your desktop MSBuild in your settings (Settings > Build, execution, deployment > Use MSBuild Version)
  • When building from the CLI, you must use MSBuild.exe. dotnet build will not work for most project types.
  • It might work in Visual Studio Code, but you have to configure build tasks in launch.json to use desktop msbuild to build.
  • You must install the tools of the platforms you intend to build. For Xamarin, that means the Xamarin Workload; for UWP install those tools as well.

More information on how SDK's are resolved can be found here.

Creating Per-RuntimeIdentifier packages

You'll need to perform a few steps:

  1. Make sure to use TargetFrameworks instead of TargetFramework, even if you're only building a single target framework. I am piggy-backing off of its looping capabilities.
  2. Set the RuntimeIdentifiers property to valid RID's (full list), separated by a semi-colon (<RuntimeIdentifiers>win;unix</RuntimeIdentifiers>).
  3. For the TFM's that you want want to build separately, set the ExtrasBuildEachRuntimeIdentifier property to true.

When you're done, you should be able to run build/pack and it'll produce a NuGet package.

Notes:

  • You must use the Sdk="MSBuild.Sdk.Extras" method for this. Using PackageReference is unsupported for this scenario.
  • While the Visual Studio context won't show each RID, it'll build for each.
  • The Extras defines a preprocessor symbol for each RID for use (win-x86 would be WIN_X86 and centos.7-x64 would be CENTOS_7_X64). Dots and dashes become underbars.
  • The default path for per-RID output assemblies and symbols in NuGet package is runtimes/<RuntimeIdentifier>/lib/<TargetFramework>.
  • RuntimeIdentifiers can be set per-TargetFramework using a condition on the property. This lets you have multiple TFM's, but only some of which have RID's.

Reference Assemblies

You will likely need to create reference assemblies to simplify development and consumption of your libraries with complex flavor (TargetFramework × RuntimeIdentifier) matrix. Reference assemblies are packed into ref/<TargetFramework> folder. Please see my two blogs articles for details.

Packing additional contents

If you need to add native assets into runtimes, the easiest way is to use:

<None Include="path/to/native.dll" PackagePath="runtimes/<rid>/native" Pack="true" />

Overriding content paths in output package

Minimal example to pack output assemblies and symbols to tools (instead of runtimes) subfolders.

<PropertyGroup>
  <ExtrasIncludeDefaultProjectBuildOutputInPackTarget>IncludeDefaultProjectBuildOutputInPack</ExtrasIncludeDefaultProjectBuildOutputInPackTarget>
</PropertyGroup>

<Target Name="IncludeDefaultProjectBuildOutputInPack">
  <ItemGroup>
    <None Include="@(RidSpecificOutput)" PackagePath="tools/%(TargetFramework)/%(Rid)" Pack="true" />
  </ItemGroup>
</Target>

For advanced options, see ClasslibPack* SDK tests and RIDs.targets file.

Migrate from the old way (VS pre-15.6)

For those who are using in a PackageReference style, you can't do that with v2.0+ of this package. So update VS to 15.6+ and manually upgrade your projects as shown below:

  1. The same as above, replace the Sdk attribute's value.
  2. Remove the workaround import specified with the old way. The import property should be MSBuildSdkExtrasTargets.
  3. Do a trial build and then compare your project with the templates in the repo's TestProjects folder to troubleshoot any issues if you encounter them.
  4. Please file a issue.

Your project diff:

- <Project Sdk="Microsoft.NET.Sdk">
+ <Project Sdk="MSBuild.Sdk.Extras">
  <!-- OTHER PROPERTIES -->
  <PropertyGroup>
    <TargetFrameworks>net46;uap10.0.16299;tizen40</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup>
-    <PackageReference Include="MSBuild.Sdk.Extras" Version="1.6.0" PrivateAssets="All"/>
  <!-- OTHER PACKAGES/INCLUDES -->
  </ItemGroup>

-  <Import Project="$(MSBuildSdkExtrasTargets)" Condition="Exists('$(MSBuildSdkExtrasTargets)')"/>
  <!-- OTHER IMPORTS -->
</Project>
- PackageReference style
+ SDK style

Note: The SDK-style project now works on Visual Studio for Mac.

Release Notes

1.6.0

  • A few properties have been changed, and the help is provided as a warning to use the new property names.

    Old Property New Property/Behaviour
    SuppressWarnIfOldSdkPack ExtrasIgnoreOldSdkWarning
    ExtrasImplicitPlatformPackageDisabled DisableImplicitFrameworkReferences + TargetFramework condition
    EmbeddedResourceGeneratorVisibilityIsInternal opposite of ExtrasEmbeddedResourceGeneratedCodeIsPublic
  • Support for WPF and Windows Forms requires an opt-in property to enable: Set ExtrasEnableWpfProjectSetup/ExtrasEnableWinFormsProjectSetup to true to include required references and default items. Note in .NET Core 3.0 these have been replaced by UseWPF/UseWindowsForms.

Single or multi-targeting

Once this package is configured, you can now use any supported TFM in your TargetFramework or TargetFrameworks element. The supported TFM families are:

  • netstandard (.NET Standard)
  • netcoreapp (.NET Core App)
  • net (.NET 5+ & .NET Framework)
  • net35-client/net40-client (.NET Framework legacy Client profile)
  • wpa (Windows Phone App 8.1)
  • win (Windows 8 / 8.1)
  • uap (Windows 10 / UWP)
  • wp (Windows Phone Silverlight, WP7+)
  • sl (Silverlight 4+)
  • tizen (Tizen 3+)
  • xamarin.android
  • xamarin.ios
  • xamarin.mac
  • xamarin.watchos
  • xamarin.tvos
  • portableNN-/portable- (legacy PCL profiles like portable-net45+win8+wpa81+wp8)

For legacy PCL profiles, the order of the TFM's in the list does not matter but the profile must be an exact match to one of the known profiles. If it's not, you'll get a compile error saying it's unknown. You can see the full list of known profiles here: Portable Library Profiles by Stephen Cleary.

If you try to use a framework that you don't have tools installed for, you'll get an error as well saying to check the tools. In some cases this might mean installing an older version of Visual Studio IDE (like 2015) to ensure that the necessary targets are installed on the machine.

msbuildsdkextras's People

Contributors

aarnott avatar andrew-boyarshin avatar appsourcers avatar azchohfi avatar batzen avatar campersau avatar clairernovotny avatar dependabot-preview[bot] avatar dependabot[bot] avatar geertvanhorrik avatar glennawatson avatar hamidzr avatar ivan-danilov avatar jbtule avatar jeromelaban avatar jkoritzinsky avatar kellogg92 avatar kexybiscuit avatar kzu avatar mattleibow avatar nirmal4g avatar perksey avatar rainersigwald avatar redth avatar sharwell avatar tranb3r avatar weitzhandler avatar wjk avatar wonyoungchoi avatar xen2 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

msbuildsdkextras's Issues

Adding MSBuildSdkExtras to csproj causes error in VS 15.6.3

After I upgraded VS to 15.6.3, the IDE could not load csproj files that target MSBuildSdkExtras via <Project Sdk="MSBuild.Sdk.Extras/1.2.2">:

image

Steps to reproduce:

  • Update Visual Studio to 15.6.3
  • Create a new solution and add a class library project targeting netstandard2.0
  • Exchange the SDK with MSBuildSdkExtras

Error message:
D:\Programming\MSBuildSdkExtrasVs15.6.3Error\MSBuildSdkExtrasVs15.6.3Error.csproj : error : Project file is incomplete. Expected imports are missing.

When I revert back to <Project Sdk="Microsoft.NET.Sdk">, I can load the project and compile it. However, I have the suspicion that there is something wrong with 15.6.3 because when I add netstandard1.0 as a TFM then the project will not build in visual studio, showing the following error message:

Error Assets file 'D:\Programming\MSBuildSdkExtrasVs15.6.3Error\obj\project.assets.json' doesn't have a target for '.NETStandard,Version=v1.0'. Ensure that restore has run and that you have included 'netstandard1.0' in the TargetFrameworks for your project. MSBuildSdkExtrasVs15.6.3Error C:\Program Files\dotnet\sdk\2.1.102\Sdks\Microsoft.NET.Sdk\build\Microsoft.PackageDependencyResolution.targets 167

However, it works fine when I compile it via msbuild on the command prompt directly.

net452 compilation failed after upgrading from 1.1.0 to 1.2.x

https://ci.appveyor.com/project/lextm/sharpsnmplib/build/1.0.286

C:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(41,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.1.4\15.0\Bin\Microsoft.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [C:\projects\sharpsnmplib\SharpSnmpLib\SharpSnmpLib.csproj]

This error happens for both 1.2.0 and 1.2.1. Switch back to 1.1.0 and then it works again.

FSharp portable language target is not located in same place as CSharp and VisualBasic

Because of this, when compiling portable, will get error:

MSBuildSdkExtras.Common.targets(118,5): error : The specified TFM 'portable-net45+sl5+win8' is not valid. Check that it's a valid combination: http://portablelibraryprofiles.apps.stephencleary.com/

Actual FSharp location:
<LanguageTargets>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.Portable.FSharp.Targets</LanguageTargets>

WPF: Adding xmlns with clr-namespace to XAML breaks build with cryptic error message

Dear Oren
Today I tried converting a bare WPF Project, i.E. one that was created by VS 15.5.7 New -> Project -> WPF App (.Net Framework) to the new csproj sdk format. I got stuck with:

1>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(419,45): error MSB4057: The target "CoreCompile" does not exist in the project.

Removing the following line from MainWindow.xaml fixes the build:

xmlns:local="clr-namespace:SdkCsprojWpfSpike"

ATM I'm quite perplexed how this can have any effect on the build outcome, but I'd guess it's about the WPF two-pass build...?!


Notably, (not) having the same line @ App.xaml doesn't matter.


Sample Project

Using your sample project I can reproduce the same issue.
The steps I performed:

1 ./Samples/WpfApplication/MainWindow.xaml

insert the following as Line 8:

xmlns:local="clr-namespace:WpfApplication"

image

2 ./Samples/WpfApplication/WpfApplication.csproj

I've had to change the target framework to net471 - because I don't have net462 installed.

3 Open Csproj & Build

.. and you'll see

1>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.WinFx.targets(419,45): error MSB4057: The target "CoreCompile" does not exist in the project.


I'd be happy providing a PR for the readme/wiki page to document this, at the least. Any directions for a header, where to place it the document?

Using MSBuild Sdk extras for UWP apps

I am currently converting everything to this new magic stuff, and have a question about UWP apps (not libraries).

Would it make sense to add something like this in by default or do you think it should be done per project (but I'd like to keep my csproj as clean as possible)?

  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x86\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>1591;1998;2008</NoWarn>
    <DebugType>full</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
    <OutputPath>bin\x86\Release\</OutputPath>
    <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <Optimize>true</Optimize>
    <NoWarn>1591;1998;2008</NoWarn>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x86</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
    <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\ARM\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <DebugType>full</DebugType>
    <PlatformTarget>ARM</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
    <OutputPath>bin\ARM\Release\</OutputPath>
    <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <Optimize>true</Optimize>
    <NoWarn>;2008</NoWarn>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>ARM</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
    <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>bin\x64\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <NoWarn>;2008</NoWarn>
    <DebugType>full</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
  </PropertyGroup>
  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
    <OutputPath>bin\x64\Release\</OutputPath>
    <DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
    <Optimize>true</Optimize>
    <NoWarn>;2008</NoWarn>
    <DebugType>pdbonly</DebugType>
    <PlatformTarget>x64</PlatformTarget>
    <UseVSHostingProcess>false</UseVSHostingProcess>
    <ErrorReport>prompt</ErrorReport>
    <Prefer32Bit>true</Prefer32Bit>
    <UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
  </PropertyGroup>

MSB4019 when compiling with new Project SDK format.

I am getting a MSB4019 when compiling with Visual Studio 15.6.4

1>C:\Program` Files\dotnet\sdk\2.1.103\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(41,3): error MSB4019: The imported project "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\Microsoft..targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
1>Done building project "aaqbr5it.tmp_proj" -- FAILED.

<Project Sdk="MSBuild.Sdk.Extras/1.2.2">
  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net471</TargetFramework>
    <EmbeddedResourceGeneratorVisibilityIsInternal>false</EmbeddedResourceGeneratorVisibilityIsInternal>
    <AssemblyName>xx</AssemblyName>
  </PropertyGroup>  
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
    <DocumentationFile>bin\Release\net471\xx.xml</DocumentationFile>
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>  
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DocumentationFile>bin\Debug\net471\xx.xml</DocumentationFile>
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>  
  <ItemGroup>
    <Reference Include="Telerik.Windows.Controls">
      <HintPath>..\..\lib\Telerik\Binaries.NoXaml\WPF45\Telerik.Windows.Controls.dll</HintPath>
    </Reference>
    <Reference Include="Telerik.Windows.Controls.Data">
      <HintPath>..\..\lib\Telerik\Binaries.NoXaml\WPF45\Telerik.Windows.Controls.Data.dll</HintPath>
    </Reference>
    <Reference Include="Telerik.Windows.Controls.FileDialogs">
      <HintPath>..\..\lib\Telerik\Binaries.NoXaml\WPF45\Telerik.Windows.Controls.FileDialogs.dll</HintPath>
    </Reference>
    <Reference Include="Telerik.Windows.Controls.Input">
      <HintPath>..\..\lib\Telerik\Binaries.NoXaml\WPF45\Telerik.Windows.Controls.Input.dll</HintPath>
    </Reference>
    <Reference Include="Telerik.Windows.Controls.Navigation">
      <HintPath>..\..\lib\Telerik\Binaries.NoXaml\WPF45\Telerik.Windows.Controls.Navigation.dll</HintPath>
    </Reference>
    <Reference Include="Telerik.Windows.Controls.RibbonView">
      <HintPath>..\..\lib\Telerik\Binaries.NoXaml\WPF45\Telerik.Windows.Controls.RibbonView.dll</HintPath>
    </Reference>
    <Reference Include="Telerik.Windows.Data">
      <HintPath>..\..\lib\Telerik\Binaries.NoXaml\WPF45\Telerik.Windows.Data.dll</HintPath>
    </Reference>
    <Reference Include="Telerik.Windows.Themes.VisualStudio2013">
      <HintPath>..\..\lib\Telerik\Binaries.NoXaml\WPF45\Telerik.Windows.Themes.VisualStudio2013.dll</HintPath>
    </Reference>
  </ItemGroup>

  <ItemGroup>
    <Compile Update="Properties\Resources.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Properties\Resources.resx">
      <Generator>PublicResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
</Project>

msbuild /t:pack fails with The "DevelopmentDependency" parameter is not supported by the "PackTask" task

Details about Problem

VS version (if appropriate): d15rel 26709.00

dotnet --info
.NET Command Line Tools (2.0.0-preview2-006497)

Product Information:
 Version:            2.0.0-preview2-006497
 Commit SHA-1 hash:  06a2093335

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.0.0-preview2-006497\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.0-preview2-25407-01
  Build    : 40c565230930ead58a50719c0ec799df77bddee9

This works fine on the latest 15.2 release, so it's a regression in 15.3.

Detailed repro steps so we can see the same problem

git clone https://github.com/AArnott/C5.git
cd c5
git checkout 9d0121eb993f7aeaec1566e22e94f563967935bc
MSBuild /t:restore
cd c5
MSBuild /t:pack

Expected

Build succeeds

Actual

msbuild /t:pack
C:\Program Files\dotnet\sdk\2.0.0-preview2-006497\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(156,15): error MSB4064: The "DevelopmentDependency" parameter is not supported by the "PackTask" task. Verify the parameter exists on the task, and it is a settable public instance property. [C:\git\c5\c5\C5.csproj]
C:\Program Files\dotnet\sdk\2.0.0-preview2-006497\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(141,5): error MSB4063: The "PackTask" task could not be initialized with its input parameters.  [C:\git\c5\c5\C5.csproj]

Ported from NuGet/Home#5584 because @rohit21agrawal tracked down the problem to:

based on what i can see from msbuild module loading log, your issue is happening because msbuild is trying to load nuget.build.tasks.pack.dll from :
'MSBuild.exe' (CLR v4.0.30319: MSBuild.exe): Loaded 'C:\Users\ragrawal.nuget\packages\msbuild.sdk.extras\1.0.3\build\NuGet.Build.Tasks.Pack\Desktop\NuGet.Build.Tasks.Pack.dll'. Cannot find or open the PDB file.
why does msbuild.sdk.extras have a copy of nguet.build.tasks.pack inside it?

Add DEFINE constants so you can use them in code

So the platforms thing is great, but sometimes it could get in the way. For example, see this project:

https://github.com/WildGums/Orc.Skia/blob/develop/src/Orc.Skia/Extensions/RectangleExtensions.cs

For this I have introduced DEFINES based on the target project:

  <!-- .NET Standard 2.0 -->
  <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
    <DefineConstants>NETSTANDARD;NETSTANDARD2_0;NS;NS20</DefineConstants>
  </PropertyGroup>
  
  <!-- .NET 4.6 -->
  <PropertyGroup Condition=" '$(TargetFramework)' == 'net46' ">
    <DefineConstants>NET;NET46;NET460</DefineConstants>
  </PropertyGroup>

  <PropertyGroup Condition=" '$(TargetFramework)' == 'net461' ">
    <DefineConstants>NET;NET46;NET461</DefineConstants>
  </PropertyGroup>
  
  <PropertyGroup Condition=" '$(TargetFramework)' == 'net462' ">
    <DefineConstants>NET;NET46;NET462</DefineConstants>
  </PropertyGroup>

  <!-- .NET 4.7 -->
  <PropertyGroup Condition=" '$(TargetFramework)' == 'net47' ">
    <DefineConstants>NET;NET47;NET470</DefineConstants>
  </PropertyGroup>

  <!-- UAP 10.0 -->
  <PropertyGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
    <DefineConstants>UAP;NETFX_CORE</DefineConstants>
  </PropertyGroup>

Would a PR for this be feasible? Happy to provide, but want to discuss first.

Classical ASP.net project support planned?

First of all thanks for this project, it really delivers what Microsoft missed when releasing the new csprojs. Since the NuGet SDK support it is also usable without any complex adjustments to the project files anymore.

The only thing I am a bit missing is the support for classical ASP.net projects. I guess from the file and project settings perspective it should be not a too big deal to add support (some rules for cshtml, aspx, asax etc.). The only thing that maybe is not that easy is telling Visual Studio that this is a web project. As you might know that a web project brings along quite some special GUI settings for debugging and publishing.

Support for this project type would really fill the gap of maintaining old and new csprojs together in a solution.

Long story short: Is there a plan to also support ASP.net projects?

Graphics files in .net standard 2.0 library do have have build action of "Resource"

We have a few graphics files in .net standard 2.0 libraries, and .net 4.7.1 libraries. We are using
MSBuildSdkExtras in these libraries. All the libraries have been converted to the new project system. However, we we try to set the build action to "Resource" it
is not an available option in .net standard 2.0 libraries. I am not sure if this is an project system error or an
MSBuildSdkExtras.

Profile328 doesn't work

Per Stephen Mccleary's blog which your readme references, I tried to add portable-net4+sl50+win8+wpa81+wp8 as a target framework, but I get these build errors when I do so:

C:\Program Files (x86)\Microsoft Visual Studio\2017\d15rel\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.TargetFrameworkInference.targets(84,5): error : Cannot infer TargetFram
eworkIdentifier and/or TargetFrameworkVersion from TargetFramework='portable-net4+sl50+win8+wpa81+wp8'. They must be specified explicitly. [C:\git\Validation.my\src\Validation\Valid
ation.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\d15rel\MSBuild\15.0\bin\Microsoft.Common.CurrentVersion.targets(1111,5): error MSB3644: The reference assemblies for framework ".
NETFramework,Version=v0.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework f
or which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies.
Therefore your assembly may not be correctly targeted for the framework you intend. [C:\git\Validation.my\src\Validation\Validation.csproj]

VS 2017 15.6+ breaks UAP builds

I just wrote a post with the following example repository:

https://github.com/GeertvanHorrik/MultiTargetingProject/blob/master/src/Ghk.MultiTargeting/Ghk.MultiTargeting.csproj

Then I read about the new 15.6 method to include the references, so I made the following changes.

Changes

  1. Replace <Project Sdk="Microsoft.NET.Sdk"> with <Project Sdk="MSBuild.Sdk.Extras/1.2.2">
  2. Remove <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
  3. Remove the package reference to MSBuild.Sdk.Extras

Result

========================================
Build
========================================
Microsoft (R) Build Engine version 15.6.82.30579 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Source\MultiTargetingProject\src\Ghk.MultiTargeting\Platforms\uap10.0\Views\MyView.xaml(1,23): error MC3074: The tag 'UserControl' does not exist in XML
namespace 'using:Catel.Windows.Controls'. Line 1 Position 23. [C:\Source\MultiTargetingProject\src\Ghk.MultiTargeting\Ghk.MultiTargeting.csproj]
C:\Source\MultiTargetingProject\src\Ghk.MultiTargeting\Platforms\uap10.0\Views\MyView.xaml(1,23): error MC3074: The tag 'UserControl' does not exist in XML
namespace 'using:Catel.Windows.Controls'. Line 1 Position 23. [C:\Source\MultiTargetingProject\src\Ghk.MultiTargeting\Ghk.MultiTargeting.csproj]
An error occurred when executing task 'Build'.
Error: One or more errors occurred.
        MSBuild: Process returned an error (exit code 1).

Build error with xamarin android or ios app referencing a multi-targeted library (The target "GetBuiltProjectOutputRecursive" does not exist in the project)

I've managed to build a multi-targeted lib for netstandard/android/ios, however when referencing this library from an android or ios app, the build of the app fails with this error:
error MSB4057: The target "GetBuiltProjectOutputRecursive" does not exist in the project.

How to reproduce the error (for android):

  • Create a new solution containing a blank Android app and a netstandard library
  • Reference the netstandard library from the android app => app build ok
  • In the netstandard library csproj, change the tfm into MonoAndroid81 (using the MSBuild.Sdk.Extras/1.5.4 sdk) => app build ok
  • In the library csproj, switch to multitargeting (rename TargetFramework into TargetFrameworks, but do not add other tfm than MonoAndroid81) => app build fails

Thoughts ?

'The target "Build" does not exist in the project' for PCL profiles 2 and 328

Target framework strings:

  • portable-net4+sl40+win8+wp70 (Profile2)
  • portable-net4+sl50+win8+wpa81+wp8 (Profile328)

Command line and output:

PS> dotnet pack /bl
Microsoft (R) Build Engine version 15.5.180.51428 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

C:\Program Files\dotnet\sdk\2.1.4\MSBuild.dll /bl /Logger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,C:\Program Files\dotnet\sdk\2.1.4\dotnet.dll /m /restore /t:pack /v:m .\Structurizr.Annotations.csproj
  Restoring packages for C:\Users\ccharabaruk\Repos\structurizr-dotnet\Structurizr.Annotations\Structurizr.Annotations.csproj...
  Generating MSBuild file C:\Users\ccharabaruk\Repos\structurizr-dotnet\Structurizr.Annotations\obj\Structurizr.Annotations.csproj.nuget.g.props.
  Generating MSBuild file C:\Users\ccharabaruk\Repos\structurizr-dotnet\Structurizr.Annotations\obj\Structurizr.Annotations.csproj.nuget.g.targets.
  Restore completed in 542.19 ms for C:\Users\ccharabaruk\Repos\structurizr-dotnet\Structurizr.Annotations\Structurizr.Annotations.csproj.
C:\Users\ccharabaruk\Repos\structurizr-dotnet\Structurizr.Annotations\Structurizr.Annotations.csproj : error MSB4057: The target "Build" does not exist in the project.
C:\Users\ccharabaruk\Repos\structurizr-dotnet\Structurizr.Annotations\Structurizr.Annotations.csproj : error MSB4057: The target "Build" does not exist in the project.
  Structurizr.Annotations -> C:\Users\ccharabaruk\Repos\structurizr-dotnet\Structurizr.Annotations\bin\Debug\netstandard1.0\Structurizr.Annotations.dll
PS>

Binlog output: msbuild.binlog.zip

Workflow Foundation: XamlAppDef

I'm trying to do a similar thing for Workflow Foundation XAML Activities.

A typical activity item is added to a csproj as follow:

<ItemGroup>
    <XamlAppDef Include="Activity1.xaml">
      <Generator>MSBuild:Compile</Generator>
      <SubType>Designer</SubType>
    </XamlAppDef>
  </ItemGroup>

What would be required to make this work, similar to WPF XAML?

Xaml file with ResourceDictionary does not get added on Pack

I want to add a style in my NuGet package for using it in a custom renderer for UWP. I created a Themes folder, added Generic.xaml, but I am not able to get it into the NuGet package.

I am using multi targeting in this library, in a similar way Xamarin.Essentials does. The package structure shows a .pri file besides the dll, but the themes folder never shows up.

What am I missing?

net45 fails on macOS

I am trying to build a simple project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net45</TargetFrameworks>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="MSBuild.Sdk.Extras" Version="1.2.0" PrivateAssets="All" />
  </ItemGroup>
  <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
</Project>

There is an error:

error MSB4019: The imported project "/Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/xbuild/15.0/Bin/Microsoft.CSharp.targets" was not found.

To fix this, I added this directly after the <Import>:

<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' and '$(OS)' != 'Windows_NT' ">
  <LanguageTargets>$(MSBuildToolsPath)\Microsoft.CSharp.targets</LanguageTargets>
</PropertyGroup>

Profile259 only works when omitting Xamarin platforms

Although this works:
portable-net45+win8+wpa81+wp8

This doesn't:
portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10

C:\Users\andarno.nuget\packages\msbuild.sdk.extras\1.0.0-rc4-17\build\netstandard1.0\MSbuildSdkExtras.Common.targets(106,5): error : The specified TFM 'portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10' is not valid. Check that it's a valid combination: http://portablelibraryprofiles.apps.stephencleary.com/ [C:\git\Validation.my\src\Validation\Validation.csproj]

Both are equivalent to Profile259. But if I leave out the Xamarin platforms then Xamarin projects don't accept the package (IIRC).

dotnet pack uniquely fails with PCL profile

When I use this setting, I get a build error:

    <TargetFrameworks>netstandard1.0;net45;portable-net45+win8+wp8+wpa81</TargetFrameworks>

msbuild /t:pack succeeds, but dotnet pack fails with:

C:\Users\andarno.nuget\packages\msbuild.sdk.extras\1.0.0-rc4.23\build\netstandard1.0\MSbuildSdkExtras.Common.targets(117,5): error : The specified TFM 'portable-net45+win8+wp8+wpa81' is not valid. Check that it's a valid combination: http://portablelibraryprofiles.apps.stephencleary.com/ [C:\git\validation\src\Microsoft.VisualStudio.Validation\Microsoft.VisualStudio.Validation.csproj]

UWP - XAML Build Defaults & Architecture Dependencies

Hey @onovotny, I've been reverse engineering this from UWPCommunityToolkit for use in my personal projects, and I have hit two road blocks.

In UWPCommunityToolkit, I see that the XAML Documents are marked as Pages, and have the Msbuild:Compile Custom Tool marked, although it is not reflected in the .csproj, is there a way to achieve this, I can't figure it out, without having to define it in the Cspoj, which adds even more Lines than original.
When I have done this, it has marked the Build Action as None with no Custom Tool.

The second road block I have hit is for Architecture Specific References I have. I am trying to convert to this Project Style so I can easily package my Shared Library with NuGet, so I have bundled Microsoft.Store.Services.SDK, and it's references for the Engagement Framework and Advertising SDK, which also bundles VC++ 2015. These dependencies fail when using AnyCPU, is there any way to reference these from this Project Style, and have it produce a clean NuGet Package?

Spring Clean-up!

I think It's that time of the year again!

Changes:

1. Build + DefaultItems Support:

  • WFF (Closes #59)
  • ASP.NET/WCF (Closes #60)
  • WinForms/WPF (Closes #66)
  • UWP (Closes #67)
  • .NET CF (Closes #48)
  • Portable Library 5.0

Some Designer features work, the ones implemented with CPS

2. SDK state:

  • Package and SDK-style (Closes #64)
  • Clean separation of Application and Library/Console support for all .NET platforms

Project build fails if AssemblyName != name of project

Hi,

my build fails because my project file is named "Fluent.Ribbon.csproj" but i specify "Fluent" as AssemblyName.
Due to this the check ('$(MSBuildProjectExtension)' == '.tmp_proj' and Exists('$(MSBuildProjectDirectory)\$(AssemblyName).csproj') fails and the correct _SdkLanguageName is not set.
I tried to work around this issue by adding things like MyProjectName to the original csproj file and modify the check to also check for $(MyProjectName).csproj but the value of MyProjectName is empty in the .tmp_proj file.

Any suggestions on how to solve this issue, without adding _SdkLanguageName to something like Directory.build.props?

Error in VSTS - The "Message" parameter is not supported by the "Error" task.

When running in VSTS I get the following errors on PCL Profile 111 projects in a solution mixed with netstandard1.1 and netstandard2.0.

MS Build parameters: /t:pack /p:PackageVersion=$(Build.BuildNumber) /p:NuGetBuildTasksPackTargets="workaround"

Error:

d:\a\1\s\packages\MSBuild.Sdk.Extras.1.1.0\build\NuGet.Workarounds.1.x.targets(12,12): error MSB4064: The "Message" parameter is not supported by the "Error" task. Verify the parameter exists on the task, and it is a settable public instance property.

Consider built-in PackageTargetFallback support

It's annoying when targeting .netstandard that compatible PCLs aren't automatically considered compatible. Folks have to define the PackageTargetFallback msbuild property manually to name the portable profile that should be allowed.

Can this package add smarts around this to define the right values for this property based on the TargetFramework, when it is .netstandard?

_ExtraSdkVersion causes build break in 15.2

Packing a project with Dev15.2 fails with this:

msbuild /t:pack

C:\Users\andre.nuget\packages\msbuild.sdk.extras\1.0.4\buildMultiTargeting\MSBuild.Sdk.Extras.targets(8,14): error MSB4086: A numeric comparison was attempted on "$(_ExtrasSdkVersion)" that evaluates to "" instead of a number, in condition "'$(IncludeBuildOutput)' == 'true' and '$(_ExtrasSdkVersion)' < 2.0". [E:\git\c5\C5\C5.csproj]

Errors do not appear in error list

Using VS 15.6.2

and the following project file

<Project Sdk="MSBuild.Sdk.Extras/1.2.2">
  <PropertyGroup>
    <TargetFramework>net461</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <None Remove="MultilingualResources\WeinCad.Controls.de.xlf" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Appccelerate.AsyncModule" Version="1.0.98" />
    <PackageReference Include="Appccelerate.Fundamentals" Version="2.8.0" />
    <PackageReference Include="Appccelerate.StateMachine" Version="4.4.0" />
    <PackageReference Include="Castle.Core" Version="3.2.0" />
    <PackageReference Include="Expression.Blend.Sdk" Version="1.0.2" />
    <PackageReference Include="Fody" Version="2.1.3" />
    <PackageReference Include="FSharp.Core" Version="4.2.3" />
    <PackageReference Include="FluentValidation" Version="7.1.1" />
    <PackageReference Include="I18N.Reactive" Version="4.1.2" />
    <PackageReference Include="LanguageExt.Core" Version="2.1.32" />
    <PackageReference Include="MahApps.Metro" Version="1.5.0" />
    <PackageReference Include="Microsoft.WindowsAPICodePack-Core" Version="1.1.0.2" />
    <PackageReference Include="Microsoft.WindowsAPICodePack-Shell" Version="1.1.0.0" />
    <PackageReference Include="Newtonsoft.Json" Version="11.0.1" />
    <PackageReference Include="Ninject" Version="3.2.2.0" />
    <PackageReference Include="Ninject.Extensions.NamedScope" Version="3.2.0.0" />
    <PackageReference Include="Serilog" Version="2.6.0" />
    <PackageReference Include="System.Diagnostics.Debug" Version="4.3.0" />
    <PackageReference Include="System.Interactive" Version="3.1.1" />
    <PackageReference Include="System.ValueTuple" Version="4.4.0" />
    <PackageReference Include="Unofficial.Blend.Interactivity" Version="1.0.0" />
    <PackageReference Include="Weingartner.Exceptional" Version="1.7.4-ci.2" />
    <PackageReference Include="Weingartner.Json.Migration" Version="311.0.0" />
    <PackageReference Include="Weingartner.ReactiveUI.Fody" Version="2.3.0-alpha.10" PrivateAssets="All" />
    <PackageReference Include="devDept.Eyeshot" Version="11.0.465" />
  </ItemGroup>
  <ItemGroup>
    <Reference Include="ReachFramework" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\Safenet\Weingartner.Products\Weingartner.Products.fsproj" />
    <ProjectReference Include="..\Safenet\Weingartner.Safenet\Weingartner.Safenet.fsproj" />
    <ProjectReference Include="..\Weingartner.Controls\Weingartner.Controls.csproj" />
  </ItemGroup>
  <ItemGroup>
    <Resource Include="View\WeinLogo.gif" />
  </ItemGroup>
  <ItemGroup>
    <XliffResource Include="MultilingualResources\WeinCad.Controls.de.xlf" />
  </ItemGroup>

  <ItemGroup>
    <EmbeddedResource Update="Properties\Resources.de.resx" />
    <Compile Update="Properties\Resources.resx.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <EmbeddedResource Update="Properties\Resources.resx">
      <Generator>I18NReactive</Generator>
      <LastGenOutput>Resources.resx.cs</LastGenOutput>
    </EmbeddedResource>
  </ItemGroup>
</Project>

image

and the following code error.

devenv_2018-03-19_12-34-13

the error does not appear in the error list. It appears if the intellisense source is used but not the build.

https://dl.dropboxusercontent.com/s/fwwj61z8g6h3bqg/2018-03-19_12-33-35.mp4

I can't send the entire project as it is not open source. If you need me to try create a fully standalone reproduction then let me know. Maybe it is obvious what the problem is from the description.

Creating project with xaml and targeting NET46, NET47 & UAP10.0 causes g.cs issues

Bear with me, I am trying to work my way through migration of a complex WPF library (that we want to convert to UWP in a slow manner, for now we support net46, net47, but are nearly ready for uap10.0 to be added).

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>net46;net47</TargetFrameworks>
    <AssemblyName>SomeCompany.Controls.DataGrid</AssemblyName>
    <RootNamespace>SomeCompany.Controls</RootNamespace>
    <DefaultLanguage>en-US</DefaultLanguage>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <WarningsAsErrors />
    <AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
    <GeneratePackageOnBuild>false</GeneratePackageOnBuild>
    <PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
    <PackageId>SomeCompany.Controls.DataGrid</PackageId>
    <PackageVersion>3.0.0-alpha0001</PackageVersion>
    <Authors>SomeCompany</Authors>
    <Description>DataGrid control.</Description>
    <PackageTags>datagrid;controls</PackageTags>
    <PackageOutputPath>$(ProjectDir)..\..\output\$(ConfigurationName)\</PackageOutputPath>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MSBuild.Sdk.Extras" Version="1.2.2" PrivateAssets="all" />
    <!-- Removed libs for ease of file -->
  </ItemGroup>

  <ItemGroup>
    <PackageReference Update="NETStandard.Library" Version="2.0.1" />
  </ItemGroup>
  
  <ItemGroup>
    <Compile Include="..\*.cs" />
    <Compile Remove="Platforms\**\*.cs;Resources\**\*.cs" />
    <Compile Remove="$(IntermediateOutputPath)\**\*.*" />
    <!-- This is here so that the conditionally included files below are all visible in VS -->
    <None Include="Platforms\**\*.*;Resources\**\*.*" />
  </ItemGroup>

  <ItemGroup>
    <Compile Update="Properties\Resources.Designer.cs">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <EmbeddedResource Update="Properties\Resources.de.resx">
      <Generator></Generator>
    </EmbeddedResource>
    <EmbeddedResource Update="Properties\Resources.es.resx">
      <Generator></Generator>
    </EmbeddedResource>
    <EmbeddedResource Update="Properties\Resources.fr.resx">
      <Generator></Generator>
    </EmbeddedResource>
    <EmbeddedResource Update="Properties\Resources.nl.resx">
      <Generator></Generator>
    </EmbeddedResource>
    <EmbeddedResource Update="Properties\Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    </EmbeddedResource>
    <EmbeddedResource Update="Properties\Resources.ru.resx">
      <Generator></Generator>
    </EmbeddedResource>
  </ItemGroup>

  <!-- .NET 4.6 -->
  <PropertyGroup Condition=" '$(TargetFramework)' == 'net46' ">
    <DefineConstants>NET;NET46</DefineConstants>
  </PropertyGroup>
  
  <ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
    <Page Include="Platforms\net\**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" />
    <Compile Update="Platforms\net\**\*.xaml.cs" SubType="Code" DependentUpon="%(Filename)" />
    <Compile Include="Platforms\net\**\*.cs" />
  </ItemGroup>

  <!-- .NET 4.7 -->
  <PropertyGroup Condition=" '$(TargetFramework)' == 'net47' ">
    <DefineConstants>NET;NET47</DefineConstants>
  </PropertyGroup>
  
  <ItemGroup Condition=" '$(TargetFramework)' == 'net47' ">
    <Page Include="Platforms\net\**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" />
    <Compile Update="Platforms\net\**\*.xaml.cs" SubType="Code" DependentUpon="%(Filename)" />
    <Compile Include="Platforms\net\**\*.cs" />
  </ItemGroup>
  
  <!-- UAP 10.0 -->
  <PropertyGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
    <DefineConstants>UAP;NETFX_CORE</DefineConstants>
  </PropertyGroup>
  
  <ItemGroup Condition=" '$(TargetFramework)' == 'uap10.0' ">
    <Page Include="Platforms\uap10.0\**\*.xaml" SubType="Designer" Generator="MSBuild:Compile" />
    <Compile Update="Platforms\uap10.0\**\*.xaml.cs" SubType="Code" DependentUpon="%(Filename)" />
    <Compile Include="Platforms\uap10.0\**\*.cs"  />
  </ItemGroup>
  
  <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
</Project>

This nearly works, there are just 2 errors:

Severity	Code	Description	Project	File	Line	Suppression State
Error		Duplicate 'Compile' items were included. The .NET SDK includes 'Compile' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultCompileItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'C:\Source\DataGrid\src\SomeCompany.Controls.DataGrid\obj\Debug\net46\Platforms\net\Controls\Views\DataGrid.g.cs'; 'C:\Source\DataGrid\src\SomeCompany.Controls.DataGrid\obj\Debug\net46\Platforms\net\Controls\Views\FunnelFiltersControl.g.cs'; 'C:\Source\DataGrid\src\SomeCompany.Controls.DataGrid\obj\Debug\net46\Platforms\net\Controls\Views\InsertTextWindow.g.cs'; 'C:\Source\DataGrid\src\SomeCompany.Controls.DataGrid\obj\Debug\net46\Platforms\net\Controls\Views\SettingsWindow.g.cs'	SomeCompany.Controls.DataGrid	C:\Program Files\dotnet\sdk\2.1.101\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets	262	
Error		Duplicate 'Compile' items were included. The .NET SDK includes 'Compile' items from your project directory by default. You can either remove these items from your project file, or set the 'EnableDefaultCompileItems' property to 'false' if you want to explicitly include them in your project file. For more information, see https://aka.ms/sdkimplicititems. The duplicate items were: 'C:\Source\DataGrid\src\SomeCompany.Controls.DataGrid\obj\Debug\net47\Platforms\net\Controls\Views\DataGrid.g.cs'; 'C:\Source\DataGrid\src\SomeCompany.Controls.DataGrid\obj\Debug\net47\Platforms\net\Controls\Views\FunnelFiltersControl.g.cs'; 'C:\Source\DataGrid\src\SomeCompany.Controls.DataGrid\obj\Debug\net47\Platforms\net\Controls\Views\InsertTextWindow.g.cs'; 'C:\Source\DataGrid\src\SomeCompany.Controls.DataGrid\obj\Debug\net47\Platforms\net\Controls\Views\SettingsWindow.g.cs'	SomeCompany.Controls.DataGrid	C:\Program Files\dotnet\sdk\2.1.101\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Sdk.DefaultItems.targets	262	

===========

What I tried:

  1. Check for any inclusion of the intermediate directory in the sdk extras, couldn't find it.
  2. Explicitly exclude these items <Compile Remove="$(IntermediateOutputPath)\**\*.*" />

What I am trying to achieve is that I can re-use the code-behind / view models, and I only need to re-supply the xaml per platform (because of no xaml standard, etc). Do you have any pointers where this might be coming from?

Thanks!

dotnet sdk import issues

Hi @onovotny. First I'd like to thank you for putting this together, this has helped me tremendously so far.

I am in the middle of converting a solution of 4 projects to use the new csproj format using the .NET SDK. One of the requirements of this project is also to convert to using dotnet for all build commands. I have to make sure I get this to build in two different environments: using VS 2017 locally, for debugging, and using the dotnet sdk on the build server. This one WPF project is giving me significant pains. It currently builds in VS 2017 just fine, but when I am running the command dotnet build --verbosity normal /p:Configuration=Release I am getting the message: C:\Program Files\dotnet\sdk\2.1.105\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(41,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\2.1.105\15.0\Bin\Microsoft.CSharp.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [*.csproj]

This is an example of my .csproj with some unnecessary stuff removed for the sake of anonymity (marked with a @@).

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
    <TargetFramework>net45</TargetFramework>
    <!--<RuntimeIdentifier>win7-x64</RuntimeIdentifier>-->
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
    <DocumentationFile>bin\$(Configuration)\@@.xml</DocumentationFile>
    <OutputPath>bin\$(Configuration)</OutputPath>
    <StartupObject>@@.App</StartupObject>
    <ApplicationIcon>Resources\@@.ico</ApplicationIcon>
    <OutputType>WinExe</OutputType>
    <LanguageTargets>$(MSBuildToolsPath)\Microsoft.CSharp.targets</LanguageTargets>
    <!--<CSharpTargets>$(MSBuildToolsPath)\Microsoft.CSharp.targets</CSharpTargets>-->
    <!--<CSharpTargets Condition="'$(CSharpTargets)' == ''">$(MSBuildToolsPath)\Microsoft.CSharp.targets</CSharpTargets>-->
  </PropertyGroup>
  <!-- Workaround for lack of XAML support using new project format. -->
  <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />
  <!--<Import Project="$(CSharpTargets)" />-->
  <!--<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />-->
  <!--<Import Project="$(BaseIntermediateOuputPath)$(OriginalProjectName).*.props" Condition=" '$(MSBuildProjectName)' != '$(OriginalProjectName)' and '$(ImportProjectExtensionProps)' != 'false' and exists('$(BaseIntermediateOuputPath)')" />-->
  <ItemGroup>
    <PackageReference Include="FontAwesome.WPF" Version="4.5.0.8" />
    <PackageReference Include="MSBuild.Sdk.Extras" Version="1.2.2" PrivateAssets="all" />
    <ProjectReference Include="..\@@.csproj" />
    <ProjectReference Include="..\@@.csproj" />
    <ProjectReference Include="..\@@.csproj" />
    <Reference Include="System" />
    <Reference Include="System.Configuration" />
    <Reference Include="System.Data" />
    <Reference Include="System.IO.Compression" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
    <Reference Include="System.Core" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="System.Xaml" />
    <Reference Include="WindowsBase" />
    <Reference Include="PresentationCore" />
    <Reference Include="PresentationFramework" />
  </ItemGroup>
  <!--<Import Project="$(BaseIntermediateOuputPath)$(OriginalProjectName).*.targets" Condition=" '$(MSBuildProjectName)' != '$(OriginalProjectName)' and '$(ImportProjectExtensionProps)' == 'true' and exists('$(BaseIntermediateOuputPath)')" />-->
  <ItemGroup>
    <Resource Include="Resources\*.png;Resources\*.ico" />
    <EmbeddedResource Include="Resources\*.dll" />
  </ItemGroup>
</Project>

Now I can't confirm this to be a result of your package, as it might be a hidden error otherwise. I can comment out the MSBuildSDKExtrasTargets Import but I get stuck with xaml compilation errors which your package seems to help. I also no longer get the error when commented though so that leads me to believe something is creating a bad import from somewhere.

I'm slowly pulling my hair out with this. Do you have any ideas?

C# define Profile* for PCLs

Consider adding this to your common .targets

  <PropertyGroup Condition="'$(_ExtrasShortFrameworkIdentifier)' == 'portable'">
    <DefineConstants>$(DefineConstants);$(TargetFrameworkProfile)</DefineConstants>
  </PropertyGroup>

That way folks can just say #if Profile328 the same way they can say #if NET40.

Xamarin.Mac20 intellisense support

I'm so glad I discovered this. I was getting really confused why Xamarin.iOS10 and Xamarin.Mac20 were not working in my VS2017-style csproj. Now that it works, how do I "using Xamarin.Mac" in the library?

This is what I currently have in my csproj:

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

  <PropertyGroup>
    <TargetFramework>Xamarin.Mac20</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="MSBuild.Sdk.Extras" Version="1.0.2" PrivateAssets="All" />
  </ItemGroup>

  <ItemGroup>
    <Compile Remove="Class1.cs" />
  </ItemGroup>
  
  <ItemGroup Condition=" '$(TargetFramework)' == 'Xamarin.Mac20' ">
    <Compile Include="Class1.cs" />
  </ItemGroup>
  
  <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" />

</Project>

MSBuild.Sdk.Extras v1.2.2 produces "...Sdk.targets(41,3): error MSB4019..."

If I use the MSBuild.Sdk.Extras v1.2.2 to build a multi targeting WPF application I get the following error:

       "C:\Users\punker76\Documents\Git\MahApps.Metro\src\MahApps.Metro.sln" (Build Ziel) (1) ->
       "C:\Users\punker76\Documents\Git\MahApps.Metro\src\MahApps.Metro.Samples\MahApps.Metro.Demo\MahApps.Metro.Demo.csproj" (Standardziel) (3) ->
       "C:\Users\punker76\Documents\Git\MahApps.Metro\src\MahApps.Metro.Samples\MahApps.Metro.Demo\hqe1ghf0.tmp_proj" (_CompileTemporaryAssembly Ziel) (4) ->
         C:\Program Files\dotnet\sdk\2.1.102\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.targets(41,3): error MSB4019: Das importierte Projekt "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\Microsoft..targets" wur
       de nicht gefunden. Vergewissern Sie sich, dass der Pfad in der <Import>-Deklaration korrekt und die Datei auf dem Datenträger vorhanden ist. [C:\Users\punker76\Documents\Git\MahApps.Metro\src\MahApps.Metro.Samples\MahApps.Metro
       .Demo\hqe1ghf0.tmp_proj]

I get this with VS 2017 15.6.2 and 15.6.3.

I tried also to re-install the sdk 2.1.102 and 2.1.101 but it still doesn't compile.

I created a branch for this here: https://github.com/MahApps/MahApps.Metro/tree/feature/VS2017_new_project_file_and_MultiTargeting_Not_Working

Go to the src folder and execute this at the command line: powershell .\build.ps1

Here is the project file

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="MSBuild.Sdk.Extras/1.2.2">
	<!-- Project properties -->
	<PropertyGroup>
		<TargetFrameworks>net47;net46;net45</TargetFrameworks>
		<AppendTargetFrameworkToOutputPath>true</AppendTargetFrameworkToOutputPath>
		<AssemblyName>MetroDemo</AssemblyName>
		<RootNamespace>MetroDemo</RootNamespace>
		<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
	</PropertyGroup>

	<PropertyGroup>
		<OutputType>WinExe</OutputType>
		<StartupObject/>
		<NoWarn>SA1652</NoWarn>
		<ApplicationIcon>mahapps.metro.logo2.ico</ApplicationIcon>
	</PropertyGroup>

	<ItemGroup>
		<ProjectReference Include="..\..\MahApps.Metro\MahApps.Metro.csproj"/>
	</ItemGroup>

	<ItemGroup>
		<Reference Include="System.Windows.Forms"/>
		<Reference Include="WindowsFormsIntegration"/>
	</ItemGroup>

	<PropertyGroup Condition=" '$(TargetFramework)' == 'net40' ">
		<DefineConstants>NET40;NET4</DefineConstants>
	</PropertyGroup>
	<PropertyGroup Condition=" '$(TargetFramework)' == 'net45' ">
		<DefineConstants>NET45;NET4_5</DefineConstants>
	</PropertyGroup>
	<PropertyGroup Condition=" '$(TargetFramework)' == 'net46' ">
		<DefineConstants>NET46;NET4_5</DefineConstants>
	</PropertyGroup>
	<PropertyGroup Condition=" '$(TargetFramework)' == 'net47' ">
		<DefineConstants>NET47;NET4_5</DefineConstants>
	</PropertyGroup>
	<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
		<DebugType>full</DebugType>
		<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
	</PropertyGroup>
	<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
		<NoWarn>1591</NoWarn>
		<DebugType>pdbonly</DebugType>
		<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
	</PropertyGroup>

	<ItemGroup>
		<ProjectCapability Include="DynamicDependentFile"/>
		<ProjectCapability Include="WindowsXaml;WindowsXamlPage;WindowsXamlCodeBehind;WindowsXamlResourceDictionary;WindowsXamlUserControl"/>
	</ItemGroup>

	<PropertyGroup>
		<ProjectConfigFileName>App.config</ProjectConfigFileName>
	</PropertyGroup>
	<!-- Items include -->
	<ItemGroup>
		<None Remove="$(MSBuildProjectDirectory)/App*.config"/>
		<None Include="paket.references"/>
		<Compile Remove="$(BaseIntermediateOutputPath)\**"/>
		<UpToDateCheckInput Include="**\*.xaml"/>
	</ItemGroup>

	<!-- Workaround to fix Intellisense file generation for XAML projects https://github.com/dotnet/project-system/issues/2488 -->
	<Target AfterTargets="_CheckCompileDesignTimePrerequisite" Name="WorkaroundForXAMLIntellisenseBuildIssue">
		<PropertyGroup>
			<BuildingProject>false</BuildingProject>
		</PropertyGroup>
	</Target>

	<Import Project="..\..\.paket\Paket.Restore.targets"/>
</Project>

Build failing when including WPF items

Today I had a really weird issue when converting a test project (of Catel) to the new project structure. It was building fine, but once I did a few (seemed simple) changes, the build suddenly broke:

PublicApiFacts.cs(11,11): error CS0246: The type or namespace name 'ApiApprover' could not be found (are you missing a using directive or an assembly reference?) [C:\CI_WS\Ws\110208\Source\Catel\src\Catel.Tests\Catel.Tests_fh3rqzzc_wpftmp.csproj]

Visual Studio also started complaining that it was unable to see the item, but it was there! Then I decided to remove a test user control I added (to check for xaml resource existence). And suddenly the error disappeared.

Not sure what's happening under the hood, but I think it's weird that adding a WPF user control breaks the build on a totally different item (e.g. a NuGet package with file references that are automatically linked in):

image

SDK-style import is lacking

I'm working on a project that I just installed the MSBuild.Sdk.Extras/1.4.0 using the SDK attribute. But now I need to define a property after the .targets are imported. I can do this with Microsoft.NET.Sdk by removing the Sdk attribute and using Import/@SDK instead. But when I try that with MSBuild.Sdk.Extras, it fails to find the SDK.

I can make this work using the old style for importing your .targets. But since you're deprecating that, I wanted to find out if you had a solution to this problem with the new style.

Add support for .NET 3.5 Compact Framework?

What do you think about adding support for .NET CF 3.5? There is a gist that explains how to do it manually: https://gist.github.com/skarllot/4953ddb6e23d8a6f0816029c4155997a

I'm not sure if the different steps like adding RedistList\FrameworkList.xml and the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\SKUs\.NETFramework,Version=v3.5,Profile=CompactFramework can be replaced by msbuild properties or targets. Do you think it's possible?

Version Changelog?

Since the readme still says to use version 1.2.2 I'm wondering what the risks are of using the latest version in NuGet (1.5.4)? I took a brief look at the commit history, but just thought it would be good to know and wondered if maybe the docs were out-of-date?

Thanks

MonoAndroid requires API Level 15

The packages worked great and I was able to compile the monoandroid project successfully. I did have to install some additional API levels (from 17 to 15), so maybe there's some configuration I'm missing to specify minimum API. I also had to set TargetFramework to monoandroid403 instead of just monoandroid, not sure of the exact implication, but works all the same. Thanks you very much for the package.

TargetPlatformVersion is 8.0 for win81 Target

When targeting win81 MSBuild Extras uses 8.0 Windows API so I changed in the following in the Windows.targets file.

	<PropertyGroup Condition="'$(TargetFramework)' == 'win81'">
		<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
		<NugetTargetMoniker>Windows,Version=v8.1</NugetTargetMoniker>
		<DefineConstants Condition="'$(DisableImplicitFrameworkDefines)' != 'true'">$(DefineConstants);NETFX_CORE;WINDOWS_APP</DefineConstants>

		<LanguageTargets>$(MSBuildThisFileDirectory)languageTargets\Windows.targets</LanguageTargets>
		<!-- Need to override the built-in implicit defines for win81 or it'll be NETCORE4_5_1 -->
		<ImplicitFrameworkDefine Condition="'$(DisableImplicitFrameworkDefines)' != 'true'">WINDOWS8_1</ImplicitFrameworkDefine>
	</PropertyGroup>

To (Added TargetPlatformVersion 8.1)

	<PropertyGroup Condition="'$(TargetFramework)' == 'win81'">
		<TargetPlatformVersion>8.1</TargetPlatformVersion>
		<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
		<NugetTargetMoniker>Windows,Version=v8.1</NugetTargetMoniker>
		<DefineConstants Condition="'$(DisableImplicitFrameworkDefines)' != 'true'">$(DefineConstants);NETFX_CORE;WINDOWS_APP</DefineConstants>

		<LanguageTargets>$(MSBuildThisFileDirectory)languageTargets\Windows.targets</LanguageTargets>
		<!-- Need to override the built-in implicit defines for win81 or it'll be NETCORE4_5_1 -->
		<ImplicitFrameworkDefine Condition="'$(DisableImplicitFrameworkDefines)' != 'true'">WINDOWS8_1</ImplicitFrameworkDefine>
	</PropertyGroup>

As Work around I use currently following Entry in my project file

<TargetPlatformVersion Condition="'$(TargetFramework)' == 'win81'">8.1</TargetPlatformVersion>

Question: VS Tooling for WPF

Synopsis

Getting WPF builds to work with the Common Project System is relatively straight forward. You've added a bunch of great tooling for the gaps.

Do you have any idea how to get Visual Studio to recognize the WPF tooling when CPS is used? I've tried everything I can think of, but I just can't make it work.

Attempt 1

To the best of my knowledge, this was determined by:

<ProjectTypeGuids>
  {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC};
  {60DC8134-EBA5-43B8-BCC9-BB4BC16C2548}
</ProjectTypeGuids>

Which equates to Visual C# | WPF. This has always been the hook for Visual Studio tooling because there's been no other way to help tooling purely by convention in these scenarios (as it's more than just programming language). This value has no bearing on the build. I've tried many combinations, but Visual Studio will not honor the value.

Attempt 2

I've tried setting this directly in Solution (*.sln) file (yuck - I know) like so:

Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC};{60DC8134-EBA5-43B8-BCC9-BB4BC16C2548}") =
"WpfApp1", "WpfApp1\WpfApp1.csproj", "{316B4CDA-1A37-46BB-B417-CDA701B04AA7}"
EndProject

But that doesn't work either.

I started to suspect that perhaps there is branching logic in the VSPackage loader that chooses a different package if Sdk="Microsoft.NET.Sdk" is present. I was able to debunk that theory though by creating a new, standard WPF application and adding Sdk="Microsoft.NET.Sdk" to it.

Attempt 3

I also remembered that Visual Studio has a concept of services that can be added to a project. I've seen it add the following to old test projects for 3rd party test frameworks as:

 <ItemGroup>
   <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
 </ItemGroup>

I was hoping that might be another place to try adding the project type GUID:

 <ItemGroup>
   <Service Include="{60DC8134-EBA5-43B8-BCC9-BB4BC16C2548}" />
 </ItemGroup>

No dice.

Final Thoughts

I also tried several combinations of deleting the .vs folder too. It didn't seem to make a difference. I think most can live without the context menu (e.g. Add Window...), but the Add File Dialog excludes all WPF content too. While it's possible to manually work around it, it's quite painful. Any thoughts, suggestions, or other experiences you can share are much appreciated.

I'm sure there many other customers wanting to make this work. If you know which Microsoft repo owns this tooling, I'm happy to also bark up their tree. Thanks.

Clean up?!

I did a clean up on this project during my journey of learning MSBuild, building new SDKs and stuff.

It's not that it needs to be cleaned but this looks better if you are trying to add, remove and/or modify the parts of the Package.

I don't want to break existing users and not break when it already works best. So, I ask here that if you are interested in accepting my PR?!

There are a few Name changes for properties, and for the Package name. Here's my project repo

Here's a preview of the new structure...

MSBuild.NET.Sdk
│   MSBuild.NET.Sdk.sln
│   
├───MSBuild.NET.Extras.Sdk
│   │   MSBuild.NET.Extras.Sdk.nuproj
│   │   MSBuild.NET.Extras.Sdk.nuspec
│   │   
│   ├───build
│   │   │   MSBuild.NET.Extras.Common.props
│   │   │   MSBuild.NET.Extras.Core.targets
│   │   │   MSBuild.NET.Extras.Sdk.props
│   │   │   MSBuild.NET.Extras.Sdk.targets
│   │   │   NuGet.Workarounds.targets
│   │   │   Platform.targets
│   │   │   
│   │   └───platforms
│   │       │   MonoAndroid.targets
│   │       │   Portable.targets
│   │       │   Silverlight.targets
│   │       │   Tizen.targets
│   │       │   Windows.targets
│   │       │   WindowsPhone.targets
│   │       │   WindowsPhoneApp.targets
│   │       │   Xamarin.iOS.targets
│   │       │   Xamarin.Mac.targets
│   │       │   Xamarin.TVOS.targets
│   │       │   Xamarin.WatchOS.targets
│   │       │   
│   │       ├───frameworkResolvers
│   │       │       Portable.v0.0.targets
│   │       │       Portable.v4.0.targets
│   │       │       Portable.v4.5.targets
│   │       │       Portable.v4.6.targets
│   │       │       
│   │       └───languageTargets
│   │               CommonAfter.targets
│   │               MonoAndroid.targets
│   │               Portable.targets
│   │               Silverlight.targets
│   │               Windows.targets
│   │               WindowsPhone.targets
│   │               Xamarin.iOS.targets
│   │               Xamarin.Mac.targets
│   │               Xamarin.TVOS.targets
│   │               Xamarin.WatchOS.targets
│   │               
│   ├───buildMultiTargeting
│   │       MSBuild.NET.Extras.Sdk.props
│   │       MSBuild.NET.Extras.Sdk.targets
│   │       NuGet.Workarounds.targets
│   │       
│   └───Sdk
│           Sdk.props
│           Sdk.targets
│           
├───MSBuild.NET.Extras.Sdk.Tests
│       Class.cs
│       MSBuild.NET.Extras.Sdk.Tests.csproj
│       Test.targets
│       
└───NuGet.Build.Tasks.Pack
    │...

msbuild /t:pack fails on 15.3 with cryptic error

Very similar to NuGet/Home#5408, with MSBuildSdkExtras 1.0.5 installed I see this build failure when I use MSBuild /t:pack on VS 15.3 installations:

C:\Program Files\dotnet\sdk\2.0.0-preview2-006497\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(141,5): error : The file '' to be packed was not found on disk. [C:\git\threading\src\Microsoft.VisualStudio.Threading\Microsoft.VisualStudio.Threading.csproj]

It works fine on 15.2 installations.

I'm filing the issue here first because the failure doesn't repro in a project where I don't use MSBuildSdkExtras.

Repro steps

git clone https://github.com/microsoft/vs-threading
cd vs-threading
git checkout 00890d8c1540c7d41dde2867391954210e632c47
cd src\Microsoft.VisualStudio.Threading
MSBuild /t:restore
MSBuild /t:pack

Please add Rider support

Currently build fails with the following error:

MSBuildSdkExtras.Common.targets(114, 5): [null] C:\Users\OlegI.nuget\packages\msbuild.sdk.extras\1.1.0-beta.69\build\netstandard1.0\MSBuildSdkExtras.Common.targets(114,5): error : The specified language targets for monoandroid71 is missing. Ensure correct tooling is installed for 'monoandroid'

Add workarounds for ClickOnce (ResolveAssemblyReferences) related issues

Would you be interested in adding workarounds for issues with publishing (clickonce) in the build process which are caused by how sdk style projects and PackageReference incorrectly sets "Private=True" for references?

Issues:

  • Netstandard support - breaks clickonce (ResolveAssemblyReferences problem)
    See dotnet/msbuild#3057
  • Using PackageReference and ClickOnce in the same Project (ResolveAssemblyReferences problem) does not work
    dotnet/msbuild#3058 )

Workaround for both of these issues can be done in the project file by adding the following code at the end so I hope it should be easy to add to the extras sdk, but I am very unsure about where to put it so that is why I put it here and dont post a PR.

The following code manually create "PublishFile" items for items which would otherwise be classified incorrectly.

<Target Name="EnsureNetstandardFilesAreIncludedInClickOnce" BeforeTargets="_DeploymentComputeClickOnceManifestInfo">
    <Message Text="Adding netstandard files to ClickOnce" />
    <ItemGroup>
      <PublishFile Include="@(_NETStandardLibraryNETFrameworkLib->'%(FileName)')" KeepMetadata="None">
        <PublishState>Include</PublishState>
        <FileType>Assembly</FileType>
      </PublishFile>
    </ItemGroup>
    <!-- Consider using ReferenceCopyLocalPaths instead, if we are missing files -->
    <Message Text="Adding nuget files to ClickOnce" />
    <ItemGroup>
      <PublishFile Include="@(ReferencePath->'%(FileName)')" Condition=" '%(ReferencePath.NuGetSourceType)' == 'Package' and '%(ReferencePath.NuGetIsFrameworkReference)' != 'true'" KeepMetadata="None">
        <PublishState>Include</PublishState>
        <FileType>Assembly</FileType>
      </PublishFile>
    </ItemGroup>

    <Message Text="Adding Private True references to ClickOnce" />
    <ItemGroup>
      <PublishFile Include="@(ReferencePath->'%(FileName)')" Condition="'%(ReferencePath.Private)' == 'True'" KeepMetadata="None">
        <PublishState>Include</PublishState>
        <FileType>Assembly</FileType>
      </PublishFile>
    </ItemGroup>
	</Target>

Cannot pair to mac server when building TFM Xamarin.iOS in Visual Studio 2017

So far, I've not been able to multi-target with xamarin.ios tfm, using vs 2017 (windows).

How to reproduce the issue:

  • in visual studio 2017 (windows)
  • create a new netstandard library
  • edit csproj, add xamarinios10 to TargetFrameworks (multitargeting with msbuildsdkextras 1.5.4)
  • "pair to mac" option is not possible in visual studio
  • as a consequence, the assembly will not be built on the mac server (warning VSX1000: No Address and User has been specified in order to establish a connection to a Mac Server)

If you add a xamarin.ios library to the same solution, the "pair to mac" option is now enabled.
However, building the first assembly still fails with the same warning.

Do you think this issue could be fixed ?
Or maybe this is an issue in xamarin or visual studio ?

Add support for Tizen TFM

NuGet 4.1+ has support for Tizen. We need to support that here by adding the TargetFrameworkIdentifier/Platform support along with the appropriate LanguageTargets.

/cc @ghuntley

What happened to MSBuild.Sdk.Extras 1.0.0-rc4.23

I have builds failing in several repos lately because the MSBuild.Sdk.Extras 1.0.0-rc4.23 package is no longer available. Did you somehow remove it from nuget.org? If you had unlisted it, I wouldn't expect it to break restore.

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.