slow-cheetah
slow-cheetah copied to clipboard
Transformations doesn't work properly in Web project with package reference format when building it using msbuild.
When i use package reference format all targets from installed packages are imported with
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
import in *.csproj file.
In web projects by default in *.csproj file placed several imports in next order:
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" /> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
When i'm trying to build and publish such solution with msbuild using next command:
msbuild.exe "C:\PATH\Web.Site.sln" /nologo /nr:false /p:DeployOnBuild=true /p:PublishProfile="FileSystem.pubxml" /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="15.0" /m /verbosity:normal
transformation for all files except Web.config is not applied.
But in case of changing order of import targets in *.csproj to the next one:
Microsoft.WebApplication.targets Microsoft.CSharp.targets
transformations begin to work.
More details in stackoverflow question
The transformations are applied, but the transformed files are removed from the list of files to copy in the CopyAllFilesToSingleFolderForPackage
target from Microsoft.Web.Publishing.targets.
<ItemGroup>
<_AllExtraFilesUnderTempFolder Include="$(WPPAllFilesInSingleFolder)\**" />
<_AllExtraFilesUnderTempFolder
Remove="@(FilesForPackagingFromProject->'$(WPPAllFilesInSingleFolder)\%(DestinationRelativePath)')" />
</ItemGroup>
Changing the order of targets does solve the problem.
The change causes target ScApplyWebTransforms
to be called at the end of the CopyAllFilesToSingleFolderForPackage
instead of before.
Any updates on this?
We have same issue, but changing order of imports does not work for us as It does not work together with Microsoft.CodeDom.Providers.DotNetCompilerPlatform
2.0 package
As I described in https://github.com/microsoft/slow-cheetah/issues/182#issuecomment-504721421, I use the following workaround in my publish profiles:
<PropertyGroup>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CollectCustomFiles;
$(CopyAllFilesToSingleFolderForMsdeployDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
<Target Name="CollectCustomFiles">
<ItemGroup>
<FilesForPackagingFromProject Remove="@(ContentWithTargetPath->'%(OriginalItemSpec)')" />
<FilesForPackagingFromProject Include="@(ContentWithTargetPath)" Exclude="@(AppConfigWithTargetPath)">
<DestinationRelativePath>%(ContentWithTargetPath.TargetPath)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
I found that I had to change the order of two items in my .csproj files, as show at: https://blog.vitaliitylyk.com/slowcheetah-and-nuget-packagereference-format/