In our DevOps build pipeline, the Build Solution task is properly transforming the "web.base.config" file to "web.config" file, however the artifact file contains only the "web.base.config" and not "web.config".
Our visual studio project file / config file setup looks like this:
…
<Content Include="Web.Base.config" />
<None Include="Web.Debug.config">
<DependentUpon>Web.Base.config</DependentUpon>
<SubType>Designer</SubType>
</None>
<None Include="Web.Dev.config">
<DependentUpon>Web.Base.config</DependentUpon>
<SubType>Designer</SubType>
</None>
<None Include="Web.QA.config">
<DependentUpon>Web.Base.config</DependentUpon>
<SubType>Designer</SubType>
</None>
…
<Target Name="BeforeBuild" Condition="'$(PublishProfileName)' == '' And '$(WebPublishProfileFile)' == ''">
<TransformXml Source="Web.Base.config" Transform="Web.$(Configuration).config" Destination="Web.config" />
</Target>
The msbuild arguments for the Build Solution task look like this:
/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:DesktopBuildPackageLocation="$(build.artifactstagingdirectory)\WebApp.zip" /p:DeployIisAppPath="Default Web Site"
In the build log file, I can see the transformation taking place successfully.
2019-01-31T21:13:32.1186618Z BeforeBuild:
2019-01-31T21:13:32.1186784Z Transforming Source File: Web.Base.config
2019-01-31T21:13:32.2198256Z Applying Transform File: Web.Dev.config
2019-01-31T21:13:32.4750975Z Output File: Web.config
2019-01-31T21:13:32.5213915Z Transformation succeeded
What do I need to do to get the transformed "Web.config" file to the artifact staging folder?
The issue is resolved - the Web.config file itself had to be part of the CSPROJ file, which it wasn't. Once I added it to the project file, I saw it published/pushed to the web site. I added it to the proj file like this:
...
<Content Include="Web.config" />
<Content Include="Web.Base.config" />
<None Include="Web.Debug.config">
<DependentUpon>Web.Base.config</DependentUpon>
<SubType>Designer</SubType>
</None>
...
Related
In order to have different configurations available for testing of different mobile OS's, I'm trying to create transform files in Rider on (config/appsettings).json files.
On the rider website there's a blog showing how to do exactly that for .config files:
XDT configuration transformations in Rider
Visual Studio has an extension which allows .json transformations called SlowCheetah: SlowCheetah - Visual Studio Marketplace
So far I haven't been able to do this in Rider on .json files.
XDT stands for XML Data Transform, therefore JSON is not supported.
But you can use different JSON files per environment, as stated in the official docs:
// appsettings.json
{
"MyKey": "My default Value",
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}
// appsettings.Development.json
{
"MyKey": "My Development Value"
}
// appsettings.Production.json
{
"MyKey": "My Production Value"
}
Please note that this is bound to the new .NET (aka .NET Core, .NET ≥ 5).
Ok, a heads up on my own question ;)
I figured I can alter the .csproj project file to create (but not generate) transform files:
<ItemGroup>
<None Update="Config\Config.Android.json">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>Config.json</DependentUpon>
</None>
<None Update="Config\Config.IOS.json">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>Config.json</DependentUpon>
</None>
<None Update="Config\Config.json">
<TransformOnBuild>true</TransformOnBuild>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<TransformOnBuild>true</TransformOnBuild>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="appsettings.IOS.json">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>appsettings.json</DependentUpon>
</None>
<None Update="appsettings.Android.json">
<IsTransformFile>true</IsTransformFile>
<DependentUpon>appsettings.json</DependentUpon>
</None>
</ItemGroup>
I'm using libsodium 0.10.0.0 package to implement password hashing.
After installing the nuget package the entries are created in package.config and project file as below:
<Reference Include="Sodium, Version=0.10.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\libsodium-net.0.10.0\lib\Net40\Sodium.dll</HintPath>
</Reference>
The following Error occur after the build:
Severity Code Description Project File Line Suppression State
Error Could not copy the file "C:\Projects\GIT\EP2\ep2-api.git\Applications\AMS\packages\runtimes\win-x86\native\libsodium.dll" because it was not found. Ace.Ams.Web
In order to fix the above error I'm manually adding the below configuration settings in csproj file but still it's not working, and then I tried to manually copy the "runtimes" folder from the libsodium package path to above path and it's working in my local build but my bamboo auto build fails.
<ItemGroup>
<None Include="runtimes\win7-x86\native\**\*">
<PackagePath>runtimes/win7-x86/native/</PackagePath>
<Pack>true</Pack>
</None>
<None Include="runtimes\win7-x64\native\**\*">
<PackagePath>runtimes/win7-x64/native/</PackagePath>
<Pack>true</Pack>
</None>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'net461'">
<None Include="runtimes\osx-x64\native\**\*">
<PackagePath>runtimes/osx-x64/native/</PackagePath>
<Pack>true</Pack>
</None>
<None Include="runtimes\linux-x64\native\**\*">
<PackagePath>runtimes/linux-x64/native/</PackagePath>
<Pack>true</Pack>
</None>
</ItemGroup>
How does one include in a c/c++ unmanaged code dll, consumed using v2 .net core compatible DllImportAttribute statements, in azure functions publish process?
I've confirmed it works in cloud deployment by manually copying, via azure storage explorer, to functions app storage account | file shares | | site/wwwroot/bin folder.
Issue is now I haven't been able to find way to have it included in vs17 | | Publish process.
Tried placing dll in \bin\$(Configuration)\netcoreapp2.1\bin folder before executing vs17 | | Publish but doesn't result in it being picked up.
In VS, right click on your Function project and Edit <FunctionProjectName>.csproj. Add items below to copy dlls we need when publishing or debugging locally.
<!-- For publish -->
<ItemGroup>
<None Include=" relative or absolute path to your dll, which is not in your project">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<!-- If you have put dlls under your project root -->
<ItemGroup>
<None Update="YourDllName.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<!-- For local debug -->
<Target Name="CopyToBin" BeforeTargets="Build">
<Copy SourceFiles="relative or absolute path to your dll" DestinationFolder="$(OutputPath)\bin" />
</Target>
We are trying to deploy an AngularJs website to azure that is build with gulp. So we develop in a source application and gulp copies the files to the dist project. The dist project is a Azure cloud source Web Role. The "compiled" files are inside of the project folder, though for some reason they are not copied.
We turned on the option Properties -> Package/Publich Web -> All files in this project folder
After deploying I only see the packes.config, web.config and bin folder. Is there anything we need to do to get the rest of the files deployed?
Yep, gulp generated files are not actually part of the project (included in the xx.csproj file) which is why "All files..." does not work. We accomplish this by adding some custom targets for build to the project file - our gulp files are in a folder called "dist".
Unload Project >> Edit... then include something like:
<Target Name="CustomCollectFiles">
<ItemGroup>
<_DistFiles Include="dist\**\*" />
<FilesForPackagingFromProject Include="%(_DistFiles.Identity)">
<DestinationRelativePath>dist\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
<_SrcFiles Include="src\**\*" />
<FilesForPackagingFromProject Include="%(_SrcFiles.Identity)">
<DestinationRelativePath>src\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
<PropertyGroup>
<TypeScriptModuleKind>AMD</TypeScriptModuleKind>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
.
.
.
<Target Name="AfterBuild" DependsOnTargets="CustomCollectFiles">
<Copy SourceFiles="#(_DistFiles)" DestinationFolder="dist" />
</Target>
With reference to this article by SamStephens and this by Sayed, I have managed to include additional dependent files during packaging when built LOCALLY using Visual Studio 2012.
The issue starts when I built the codes in TFS. Looking through the logs, it looks like the CopyAllFilesToSingleFolderForMsdeployDependsOn is not hooked on.
CopyAllFilesToSingleFolderForMsdeployDependsOn =
;
;
CopyAllFilesToSingleFolderForPackageDependsOn =
;
;
So I have a Deployment.csproj with a CreatePackage.targets file and in this target file, it would build the web application project. The following is the snippet of the file which I combine what I learned from both the articles stated earlier.
<!-- Create Web Deploy package for local build. -->
<Target Name="WebPackage" Condition="'$(TfsBuild)' == ''">
<!-- MSBuild the project. -->
<MSBuild Projects="..\webapplication.csproj"
Targets="Package"
Properties="
Platform=$(Platform);
VisualStudioVersion=$(VisualStudioVersion);
Configuration=$(Configuration);
WebPublishMethod=Package;
ExcludeApp_Data=false;
DeployOnBuild=true;
DeployTarget=Package;
PackageAsSingleFile=true;
PackageLocation=$(PackageOutputDirectory);
PublishProfile=$(MSBuildThisFileFullPath);
ExcludeFoldersFromDeployment=Scripts;
ExcludeFilesFromDeployment=parameters.xml;">
</MSBuild>
</Target>
<PropertyGroup>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
DefineAssemblies;
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForMsdeployDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
<AssemblySource Condition="'$(TfsBuild)' == ''">$(SolutionDir)\ProjectA\bin\$(Configuration)\ProjectA.dll</AssemblySource>
<AssemblySource Condition="'$(TfsBuild)' == 'true'">$(OutputDirectory)ProjectA.dll</AssemblySource>
<Target Name="DefineAssemblies">
<ItemGroup>
<FilesToInclude Include="$(AssemblySource)">
<Dir>lib</Dir>
</FilesToInclude >
</ItemGroup>
</Target>
<Target Name="CustomCollectFiles">
<ItemGroup>
<FilesForPackagingFromProject Include="#(FilesToInclude )">
<DestinationRelativePath>%(FilesToInclude.Dir)\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
So the question is: Why is this working nicely locally in VS2012 and not in the TFS build?
I've been stuck in this for two days now so I would really appreciate any help.