TFS Builder Server missing config file - msbuild

I have a project that builds without errors on our build server (2012). The issue is we are not getting the transformed app.config.
Using transform preview I see that the transform works correctly. In the .csproj file, I see that the app.config and all of the transforms are added and transform on build are set to true.
<ItemGroup>
<None Include="App.config">
<TransformOnBuild>true</TransformOnBuild>
</None>
<None Include="App.Debug.config">
<DependentUpon>App.config</DependentUpon>
<IsTransformFile>True</IsTransformFile>
</None>
<None Include="App.DEV1.config">
<DependentUpon>App.config</DependentUpon>
<IsTransformFile>True</IsTransformFile>
</None>
<None Include="App.PROD.config">
<DependentUpon>App.config</DependentUpon>
<IsTransformFile>True</IsTransformFile>
</None>
<None Include="App.QA1.config">
<DependentUpon>App.config</DependentUpon>
<IsTransformFile>True</IsTransformFile>
</None>
<None Include="App.Release.config">
<DependentUpon>App.config</DependentUpon>
<IsTransformFile>True</IsTransformFile>
</None>
<None Include="App.UAT1.config">
<DependentUpon>App.config</DependentUpon>
<IsTransformFile>True</IsTransformFile>
</None>
Other projects in the build have the correct config files. Here is a relevant section of the build log.
10:53:46.166 66>Target "_CopyAppConfigFile: (TargetId:2226)" in file "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets" from project "D:\1_91\Sources\Path1\Path2\Path3\projname.csproj" (target "CopyFilesToOutputDirectory" depends on it):
Building target "_CopyAppConfigFile" completely.
Output file "D:\1_91\Binaries\Path3\projname.exe.config" does not exist.
Task "Copy" (TaskId:1543)
Copying file from "App.config" to "D:\1_91\Binaries\Path3\projname.exe.config". (TaskId:1543)
Done executing task "Copy". (TaskId:1543)
It does not find the transformed config and so it replaces it with the default config. What could I try to fix this issue?

I installed Configuration Transformation and it installed the transform instructions to the csproj file.

Related

Error using C++/CLI dll in Azure function (zip deployed)

So I have:
a c++/cli wrapper withini a clr c++ dll
a c# net6 azure function which is referencing the c++/cli project
The issue:
It works perfectly when I'm testing it in local (with visual studio)
When it's published (zip) on Azure I can call functions that don't use the c++/cli dll,
but when I'm calling (via Test/Run button) a function that use my c++/cli lib
I have this error code 500 Internal Server Error and this error message:
Could not load file or assembly 'C:\home\site\wwwroot\bin\MyCliDll.dll'. Format of the executable (.exe) or library (.dll) is invalid.
I have try a lot of different publishing configuration but non of them worked.
at this point I don't have any idea of what to change i order to make it works, is it a compatibility problem between my c++ and Azure ?
In case, here both of my setup:
<!--Publishing Setup-->
<Project>
<PropertyGroup>
<UserName>XXXXX</UserName>
<WebPublishMethod>ZipDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>x64</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>XXXXXX</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>false</LaunchSiteAfterPublish>
<ResourceId>XXXXXXXX</ResourceId>
<_SavePWD>true</_SavePWD>
<PublishUrl>XXXXXXXX</PublishUrl>
<TargetFramework>net6.0</TargetFramework>
<SelfContained>false</SelfContained>
<SkipExtraFilesOnServer>true</SkipExtraFilesOnServer>
</PropertyGroup>
</Project>
<!--csproj-->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Library</OutputType>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
<IncludeAllContentForSelfExtract>true</IncludeAllContentForSelfExtract>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Storage.Blobs" Version="12.11.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\MyCliDllProject\build\MyCliDll.vcxproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Ok I feel a bit dumb I just needed to go to the portal Azure in Configuration->General Settings->Platform and set it to 64 bit...

How to copy contentFiles of NuGet package references via MSBuild Copy task

We have several repositories and each one has its own .editorconfig. Obviously, these are not synced, which is why I would like to distribute the .editorconfig from our framework solution (along with other files) via NuGet package to all our repositories/solutions and copy it via a simple Copy build Task to the solution directory.
I attempted to do the following:
Create a project "EditorConfigDistribution", which is supposed to contain the master .editorconfig file.
<Project Sdk="Microsoft.NET.Sdk">
...
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<NoDefaultExcludes>true</NoDefaultExcludes>
</PropertyGroup>
<ItemGroup>
<Content Include=".editorconfig">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<Pack>true</Pack>
<PackageCopyToOutput>false</PackageCopyToOutput>
<PackagePath>contentFiles\any\any\content</PackagePath>
</Content>
</ItemGroup>
</Project>
This all works as expected and I do get the desired .editorconfig file in my project from the other solutions and it is referenced as shortcut in a folder content/.editorconfig (see EditorConfigConsumer Project Structure).
The file is only a reference to C:\Users\<user>\.nuget\packages\editorconfigdistribution\1.0.0\contentFiles\any\any\content\.editorconfig.
Now, I want to copy that .editorconfig file via build task:
<Project Sdk="Microsoft.NET.Sdk">
...
<ItemGroup>
<PackageReference Include="EditorConfigDistribution" Version="1.0.0">
</PackageReference>
</ItemGroup>
<Target Name="CopyEditorConfig" BeforeTargets="BeforeBuild">
<ItemGroup>
<EditorConfigFileToCopy Include="$(MSBuildProjectDirectory)\content\.editorconfig" />
</ItemGroup>
<Copy SourceFiles="#(EditorConfigFileToCopy)" DestinationFolder="$(MSBuildProjectDirectory)\.." SkipUnchangedFiles="true" UseHardlinksIfPossible="false" />
</Target>
</Project>
However, I do get the following error:
Error MSB3030: Could not copy the file "C:\Users\weberma9\source\repos\<some_path>\EditorConfigConsumer\content\.editorconfig" because it was not found. (20, 5)
I can understand that the file (since it is a shortcut) cannot be found, but I just cannot figure out a way to reference that shortcut correctly in my build task.
What do I need to change in that line <EditorConfigFileToCopy Include="$(MSBuildProjectDirectory)\content\.editorconfig" />?
Of course, if you have better approaches to my general problem - I'm glad to hear about it.
I was able to find a solution for my problem:
I not only provide the .editorconfig, but also the Copy-Build task via my EditorConfigDistribution project, which looks like this now:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<NoDefaultExcludes>true</NoDefaultExcludes>
</PropertyGroup>
<ItemGroup>
<None Include="..\..\.editorconfig">
<Link>Rules\.editorconfig</Link>
<Pack>true</Pack>
<PackageCopyToOutput>false</PackageCopyToOutput>
<PackagePath>Rules\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<None Include="build\**">
<Pack>true</Pack>
<PackageCopyToOutput>false</PackageCopyToOutput>
<PackagePath>build\</PackagePath>
</None>
</ItemGroup>
</Project>
The .props file is straightforward and due to the convention that <package_id>.props and <package_id>.target are added to projects that consume the package (see Include MSBuild props and targets in a package), it will always be executed before 'BeforeBuild'.
EditorConfigDistribution.props (placed in build folder):
<Project>
<Target Name="CopyEditorConfig" BeforeTargets="BeforeBuild">
<ItemGroup>
<EditorConfigFilesToCopy Include="$(MSBuildThisFileDirectory)..\Rules\.editorconfig" />
</ItemGroup>
<Copy SourceFiles="#(EditorConfigFilesToCopy)" DestinationFolder="$(SolutionDir).." SkipUnchangedFiles="true" UseHardlinksIfPossible="false" />
</Target>
</Project>

Why does dotnet build not include folders when running release?

I am trying to build a .net core 3 Web App in release mode, but the folders wwwroot and ClientApp are missing from the published source.
I tried adding them manually to the .csproj like below, and the folders get included but none of the content in them.
Any ideas?
<ItemGroup>
<None Include="ClientApp\*" />
<None Include="wwwroot\*" />
</ItemGroup>
You can try the ** wildcard to include everything in these folders. The documentation states:
The ** wildcard character sequence matches a partial path.
So your ItemGroup would look like this:
<ItemGroup>
<None Include="ClientApp\**" />
<None Include="wwwroot\**" />
</ItemGroup>

Donet core Conflicts between different versions of "Microsoft.AspNetCore.Authentication.Abstractions"

I am currently working on major refactoring of project and in the process trying to remove all Warnings our code base had. Finally down to 11 Warnings, but can't really see what is going on with 9 of them, which all seem to be related. Something like:
Severity Code Description Project File Line Suppression State
Warning MSB3277 Found conflicts between different versions of
"Microsoft.AspNetCore.Authentication.Abstractions" that could not be
resolved. These reference conflicts are listed in the build log when
log verbosity is set to
detailed. #######.Test.Integration C:\Program Files
(x86)\Microsoft Visual
Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets 2106
I have Consolidated the nuget package versions.
Checked the Csproj file and it seemed fine. (See below.)
All warnings are in Microsoft.AspNetCore.*
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FakeItEasy" Version="5.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\###\###API.csproj" />
<ProjectReference Include="..\###\###.Core.csproj" />
<ProjectReference Include="..\###\###.Data.csproj" />
</ItemGroup>
</Project>
Try to use the web SDK (Microsoft.NET.Sdk.Web instead of Microsoft.NET.Sdk) and add a package reference to Microsoft.AspNetCore.App without specifying a version
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>
Refer to Integration and unit tests no longer work on ASP.NET Core 2.1 failing to find assemblies at runtime
https://github.com/dotnet/sdk/issues/2253

Dotnet watcher - Illegal characters in path -- what could cause this error?

Can anyone help us understand why dotnet watch is causing our applications to crash?
I'm using dotnet new mvc and yo aspnetcore-spa to create apps in visual studio code. Both work fine until I try to add a reference to DotNet Watcher tools using example at https://github.com/aspnet/DotNetTools/tree/dev/src/Microsoft.DotNet.Watcher.Tools to insert reference in csproj file:
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
</ItemGroup>
After adding to csproj and dotnet restore, the application throws an error and fails and is unrecoverable. It has to be deleted and I have to start from scratch.
Full csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>
netcoreapp1.1
</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0" />
</ItemGroup>
</Project>
The error thrown is below and happens no matter where we create the application on disk or what it is named.
C:\Program Files\dotnet\sdk\1.0.1\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\Microsoft.NET.Sdk.Publish.targets(90,5): error MSB4184: The expression "[System.IO.Path]::GetFullPath(C:\test\obj\Debug\ [C:\test\test.csproj]
C:\Program Files\dotnet\sdk\1.0.1\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\Microsoft.NET.Sdk.Publish.targets(90,5): error MSB4184: netcoreapp1.1 [C:\test\test.csproj]
C:\Program Files\dotnet\sdk\1.0.1\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\Microsoft.NET.Sdk.Publish.targets(90,5): error MSB4184: \PubTmp)" cannot be evaluated. Illegal characters in path. Parameter name: path [C:\test\test.csproj]
Our environment is:
.NET Command Line Tools (1.0.1)
Microsoft .NET Core Shared Framework
Host Version : 1.1.0
Build: 928f77c4bc3f49d892459992fb6e1d5542cb5e86
Visual Studio Code v 1.10.2
Windows 10
Problem solved. An extension named "XML Formatter" was rewriting the csproj file on save and adding hard returns and tabs. Removing this extension, restoring csproj to it's original state, adding back in the DotNetCliToolReference code block and rebuilding via dotnet restore solved the issue.