3

EDIT: more details

I'm working on converting the Sitecore.Demo.Retail project from VS 2015 (.NET core preview) to VS 2017 and latest .NET Core.

The solution now builds perfectly fine in Visual Studio 2017 but the issue I encounter is when trying to run a build using msbuild 15. It fails on trying to copy the .config file from the obj\debug\net452 folder but for some reason it's adding the full .csproj name

The issue is that the Publish.Targets are doing something weird with the .config file.

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.NET.Sdk\build\Microsoft.NET.Publish.targets(128,5):
error MSB3030: Could not copy the file "obj\Debug\net452\Sitecore.Foundation.Commerce.Engine.csproj.code.exe.config" because it was not found. 

[C:\Projects\Sitecore.Demo.Retail\src\Foundation\Commerce\Engine\code\Sitecore.Foundation.Commerce.Engine.csproj]

It's prepending the full project name (including .csproj) to the name of the config file rather than just using the AssemblyName.

In this case, Sitecore.Foundation.Commerce.Engine.csproj is the project and code is the AssemblyName (it will change). As you can see it's looking for "Sitecore.Foundation.Commerce.Engine.csproj.code.exe.config" which doesn't exist. code.exe.config does exist though.

I'm happy to give GitHub repo access to anyone interested in helping figure this one out with me as it's blocking us from making the repository public.

so code.exe.config is resolved as Sitecore.Foundation.Commerce.Engine.csproj.code.exe.config

OUTPUT snippet from MSBuild:

08:13:09.957     1>Target "GenerateBindingRedirectsUpdateAppConfig: (TargetId:127)" in file "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\amd64\Microsoft.Common.CurrentVersion.targets" from project "C:\Projects\Sitecore.Demo.Retail\src\Foundation\Commerce\Engine\code\Sitecore.Foundation.Commerce.Engine.csproj" (target "ResolveReferences" depends on it):
                   Set Property: AppConfig=obj\Debug\net452\Sitecore.Foundation.Commerce.Engine.csproj.code.exe.config
                   Added Item(s): 
                       AppConfigWithTargetPath=
                           obj\Debug\net452\Sitecore.Foundation.Commerce.Engine.csproj.code.exe.config
                                   TargetPath=code.exe.config

Here is the Sitecore.Foundation.Commerce.Engine.csproj content:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>
    <TargetFramework>net452</TargetFramework>
    <PreserveCompilationContext>false</PreserveCompilationContext>
    <AssemblyName>code</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageId>code</PackageId>
  </PropertyGroup>

  <!--<ItemGroup>
    <None Update="wwwroot\**\*">
      <CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
    </None>
  </ItemGroup>-->

  <ItemGroup>
    <ProjectReference Include="..\..\legacyCommerce\Plugin.Sample.Habitat\Plugin.Sample.Habitat.csproj" />
    <ProjectReference Include="..\..\legacyCommerce\Plugin.Sample.Payments.Braintree\Plugin.Sample.Payments.Braintree.csproj" />
    <ProjectReference Include="..\..\legacyCommerce\Sitecore.Commerce.Plugin.AdventureWorks\Sitecore.Commerce.Plugin.AdventureWorks.csproj" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.3" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.2" />
    <PackageReference Include="Microsoft.AspNetCore.OData" Version="6.0.0-alpha1-rtm-121216" />
    <PackageReference Include="Microsoft.ApplicationInsights" Version="2.1.0" />
    <PackageReference Include="Serilog" Version="2.4.0" />
    <PackageReference Include="Sitecore.Commerce.Core" Version="1.0.2301" />
    <PackageReference Include="Serilog.Sinks.Literate" Version="2.1.0" />
    <PackageReference Include="Serilog.Sinks.RollingFile" Version="3.3.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" />
    <PackageReference Include="Serilog.Extensions.Logging" Version="1.4.0" />
    <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="1.0.2" />
    <PackageReference Include="Sitecore.Commerce.Provider.FileSystem" Version="1.0.2301" />
    <PackageReference Include="Sitecore.Framework.Rules" Version="1.1.12" />
    <PackageReference Include="Sitecore.Framework.Rules.Serialization" Version="1.1.12" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
    <PackageReference Include="Sitecore.Framework.Diagnostics" Version="1.1.4" />
  </ItemGroup>

  <ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
    <Reference Include="System" />
    <Reference Include="Microsoft.CSharp" />
  </ItemGroup>

</Project>
4
  • We configure msbuild to use v14 as a workaround: msbuild({..., toolsVersion: 14.0, properties: { ..., VisualStudioVersion: "14.0" }}). This requires v14 to be installed on your system off course.
    – Thomas D
    Commented Mar 16, 2017 at 8:25
  • Thanks for your comment - the issue is that the Sitecore.Demo.Retail solution has a few .NET Core projects so MSBuild 14 won't work. Switching to MSBuild 14 initially gives an XML Namespace error but when I add the msbuild/2003 entry in the <Project> element I then get different errors, one of which being "The attribute 'Version' in <PackageReference> is unrecognized. I also get "There is no target in the project" So I think I need to get MSBuild 15 working. Commented Mar 16, 2017 at 10:37
  • Did you update gulp-msbuild on your NPM stack? See details on this answer. sitecore.stackexchange.com/questions/4907/…
    – Mark Cassidy
    Commented Mar 17, 2017 at 8:45
  • I did thanks for your comment. It wouldn't build at all (didn't resolve the correct msbuild path without the updated version). I logged an issue on GitHub and posted the log from msbuild. Someone has taken a look at it and found some weirdness - still working it out: github.com/Microsoft/msbuild/issues/1873 Commented Mar 17, 2017 at 10:10

1 Answer 1

1

I ended up creating a new build configuration and excluding the .NET Core projects from the build configuration. I then pass the build configuration as a parameter to msbuild and I build the .NET Core projects separately using dotnet CLI

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.