novotnyllc / MSBuildSdkExtras

Extra properties for MSBuild SDK projects
MIT License
347 stars 42 forks source link

Profile328 doesn't work #1

Closed AArnott closed 7 years ago

AArnott commented 7 years ago

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]

clairernovotny commented 7 years ago

Thanks, will fix

clairernovotny commented 7 years ago

Hmmm...I can't repro it, do you have a branch where I can see this? Did you remember to add <Import Project="$(MSBuildSDKExtrasTargets)" Condition="Exists('$(MSBuildSDKExtrasTargets)')" /> to the end of your csproj file?

I just used your exact TFM and it worked for me...

AArnott commented 7 years ago

Peculiar. Anyway, yes here is the commit that can repro it: https://github.com/AArnott/Validation/commit/7f904e6597e67a1cd4ab515b5f209ad83352ff76

Just comment out the extra property group I also added as a workaround and it should repro for you.

clairernovotny commented 7 years ago

Can you try the latest from the MyGet feed? https://www.myget.org/F/msbuildsdkextras/api/v3/index.json it's more robust in the contains searches (though I wasn't able to repro it anyway)

clairernovotny commented 7 years ago

Will try your repo shortly

AArnott commented 7 years ago

sure

clairernovotny commented 7 years ago

trying that commit, I get the following error. Restore was successful, build failed on the netstandard1.0 version

Assumes.cs(60,33): error CS1061: 'IEnumerable<T>' does not contain a definition for 'Any' and no extension method 'Any'
 accepting a first argument of type 'IEnumerable<T>' could be found (are you missing a using directive or an assembly r
eference?) [C:\dev\Validation\src\Validation\Validation.csproj]
AArnott commented 7 years ago

ya, you got further than I got with your 17 build

AArnott commented 7 years ago

I'm still seeing a failure on the portable-net40 one on mine, even with your 18 build

AArnott commented 7 years ago

I'll try to step through it (mentally at least) with your latest .targets to figure out what's going wrong. Perhaps with a /pp: step that I can share if I can't figure it out.

clairernovotny commented 7 years ago

What's weird is that if I just leave that TFM in your project, it fails for me too. But if I put that TFM I the TestLibrary that's part of this repo, it builds fine. It also builds/tests fine when part of sdk/pulls/889

AArnott commented 7 years ago

I just found this in my Validation.csproj.nuget.g.props file. See anything missing? (I think I do)

  <ImportGroup Condition=" '$(TargetFramework)' == '' AND '$(ExcludeRestorePackageImports)' != 'true' ">
    <Import Project="$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\buildMultiTargeting\MSBuild.Sdk.Extras.props" Condition="Exists('$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\buildMultiTargeting\MSBuild.Sdk.Extras.props')" />
  </ImportGroup>
  <ImportGroup Condition=" '$(TargetFramework)' == 'net40' AND '$(ExcludeRestorePackageImports)' != 'true' ">
    <Import Project="$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\build\portable-net4+wp7+sl4+win8\MSBuild.Sdk.Extras.props" Condition="Exists('$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\build\portable-net4+wp7+sl4+win8\MSBuild.Sdk.Extras.props')" />
  </ImportGroup>
  <ImportGroup Condition=" '$(TargetFramework)' == 'net45' AND '$(ExcludeRestorePackageImports)' != 'true' ">
    <Import Project="$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\build\netstandard1.0\MSBuild.Sdk.Extras.props" Condition="Exists('$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\build\netstandard1.0\MSBuild.Sdk.Extras.props')" />
  </ImportGroup>
  <ImportGroup Condition=" '$(TargetFramework)' == 'netstandard1.0' AND '$(ExcludeRestorePackageImports)' != 'true' ">
    <Import Project="$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\build\netstandard1.0\MSBuild.Sdk.Extras.props" Condition="Exists('$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\build\netstandard1.0\MSBuild.Sdk.Extras.props')" />
  </ImportGroup>
  <ImportGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' AND '$(ExcludeRestorePackageImports)' != 'true' ">
    <Import Project="$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\build\netstandard1.0\MSBuild.Sdk.Extras.props" Condition="Exists('$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\build\netstandard1.0\MSBuild.Sdk.Extras.props')" />
  </ImportGroup>
  <ImportGroup Condition=" '$(TargetFramework)' == 'portable-net45+win8+wpa81+wp8' AND '$(ExcludeRestorePackageImports)' != 'true' ">
    <Import Project="$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\build\netstandard1.0\MSBuild.Sdk.Extras.props" Condition="Exists('$(NuGetPackageRoot)msbuild.sdk.extras\1.0.0-rc4.18\build\netstandard1.0\MSBuild.Sdk.Extras.props')" />
  </ImportGroup>
AArnott commented 7 years ago

The version that produced this is at tip of fix20 at this point.

AArnott commented 7 years ago

Your targets aren't getting imported because there's nothing in the above xml snippet to import portable-net40-*

AArnott commented 7 years ago

When I change my net4 TFM to exactly your package's build folder name (portable-net4+wp7+sl4+win8) it works.

AArnott commented 7 years ago

(at least, the .props gets imported)

AArnott commented 7 years ago

OK: it's because your folder is missing wpa as a target.

AArnott commented 7 years ago

rename your package's build folder from portable-net4+wp7+sl4+win8 to portable-net4+wp7+wpa+sl4+win8 and you've got it made it seems.

clairernovotny commented 7 years ago

good catch

clairernovotny commented 7 years ago

Can you try one thing for me? portable-net4+wp7+sl4+win8+wpa81 isn't really a real TFM, I think... but I think it should work with any as the folder name as the ultimate fallback. Can you test that out and see if that works? If so, that seems like a better failsafe than an invalid TFM combo.

AArnott commented 7 years ago

hold on. wpa doesn't belong in a net40 era, does it? Nor does win8. I thought these new platforms were only available for net45 era PCLs.

AArnott commented 7 years ago

I think it should work with any as the folder name as the ultimate fallback. Can you test that out and see if that works?

Tried. It doesn't work.

clairernovotny commented 7 years ago

Profile 328 is sl5, not sl4 that's the difference... but if it works for you and nuget evaluates it correctly, then so be it :)

AArnott commented 7 years ago

I wasn't targeting sl4. That just came from your folder name.

clairernovotny commented 7 years ago

yup, that was there because some of the PCL profiles include wp7 and sl4. I just pushed a new build with portable-net4+wp7+sl4+win8+wpa81, it should be on the MyGet feed in a few min. If you can validate that package, I'll push it to NuGet.

Thanks for finding this! I missed it because my test project doesn't use NuGet as it includes the targets directly.

AArnott commented 7 years ago

hold on. wpa doesn't belong in a net40 era, does it?

It does. I just confirmed. So your fix looks good. I'll try your latest CI.

AArnott commented 7 years ago

It works. Thanks.

clairernovotny commented 7 years ago

-19 will be on nuget in a few min, thanks!