If I add two subfolders with the same name in an F# project I get this error:
The folder strucure is:
<ItemGroup>
<Compile Include="Test\File1.fs" />
<Compile Include="SubFolder\Test\File2.fs" />
</ItemGroup>
Does anyone know a work around?
Make sure you dont have in your project
<ItemGroup>
<Compile Include="Folder1\File1.fs" />
<Compile Include="SubFolder\Test\File2.fs" />
<Compile Include="Folder1\another.fs" />
</ItemGroup>
but instead
<ItemGroup>
<Compile Include="Folder1\File1.fs" />
<Compile Include="Folder1\another.fs" />
<Compile Include="SubFolder\Test\File2.fs" />
</ItemGroup>
(contiguous folders mentions)
This causes a bug which has been reported.
If you can isolate and reproduce a bug, please send it to fsbugs#microsoft.com, the team really looks after those pbs.
Related
What I do
I have multiple tt files in my project file.
Therefore, many entries are created for each file as follows.
<ItemGroup>
<Compile Update="Sample.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Sample.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="Sample.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Sample.cs</LastGenOutput>
</None>
</ItemGroup>
I want to prevent making this entry for every tt file.
What I have tried
The following statements were made using wildcards.
<ItemGroup>
<Compile Update="**/*.tt.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>%(Filename)</DependentUpon>
</Compile>
<None Update="**/*.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>%(Filename).tt.cs</LastGenOutput>
</None>
</ItemGroup>
The following settings are used in the tt file.
<## output extension="tt.cs" #>
Problem
T4 works, but when I save the tt file, the following entry is added to csproj.
<ItemGroup>
<Compile Update="Sample.tt.cs">
<DesignTime>True</DesignTime>
</Compile>
</ItemGroup>
Question
How can I prevent entries from being added?
We can see the description of Update from this page
Enables you to modify metadata of an item; typically used to override
the default metadata of specific items after a group of items is
intially specified (such as with a wildcard).
Update overrides Compile when save the tt file, so this code will be added to scproj. This doesn't seem to prevent.
<ItemGroup>
<Compile Update="Sample.tt.cs">
<DesignTime>True</DesignTime>
</Compile>
</ItemGroup>
I have a .NET solution with the projects below:
Console: Console .NET Core 2.2
Domain: .NET Standard 2.0
Domain.Tests: Console .NET Core 2.2 (XUnit)
Infrastructure: .NET Standard 2.0
My Domain.Tests.fsproj is defined as:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<IsPackable>false</IsPackable>
<GenerateProgramFile>false</GenerateProgramFile>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FsCheck" Version="3.0.0-alpha4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
</ItemGroup>
<ItemGroup>
<Compile Include="Dsl.fs" />
<Compile Include="OpenAccountTests.fs" />
<Compile Include="CloseAccountTests.fs" />
<Compile Include="DepositCashTests.fs" />
<Compile Include="WithdrawCashTests.fs" />
<Compile Include="WireMoneyTests.fs" />
<Compile Include="RequestAddressChangeTests.fs" />
<Compile Include="RequestEmailChangeTests.fs" />
<Compile Include="RequestPhoneNumberChangeTests.fs" />
<Compile Include="ValidateAddressChangeTests.fs" />
<Compile Include="ValidateEmailChangeTests.fs" />
<Compile Include="ValidatePhoneNumberChangeTests.fs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Domain\Domain.fsproj" />
</ItemGroup>
</Project>
But when compiling the solution I have the following warning:
ValidatePhoneNumberChangeTests.fs(102, 35): [FS0988] Main module of program is empty: nothing will happen when it is run
I checked that answer on SO and adding do() at the end of the last file of Domain.Tests: ValidatePhoneNumberChangeTests.fs didn't do anything.
What can I do to get rid of this warning?
#rmunn is on the right track in the comments. <OutputType> defaults to Library when TargetFramework is netstandardXX or net4XX, and Exe when TargetFramework is netcoreappXX.
Setting <OutputType>Library</OutputType> is IMO the best way to fix this, rather than adding an entry point that won't be called.
<TargetFramework>netcoreapp2.2</TargetFramework>
This specifies the Domain.Tests project as an executable
If you only need it to be a class library then change it to
<TargetFramework>netstandard2.0</TargetFramework>
If you simply want to remove the warning you can add a main method by either adding this at the end of ValidatePhoneNumberChangeTests.fs or in a Program.fs at the end of the compilation order
[<EntryPoint>]
let main argv =
0
Just remove the Program.fs and OutputType (it doesn't work for me as well). Set GenerateProgramFile to true in PropertyGroup like that:
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<IsPackable>false</IsPackable>
<GenerateProgramFile>true</GenerateProgramFile>
</PropertyGroup>
cheers!
Every time I build my .NET Core project, it adds a deeper folder containing the .csproj file in \bin\release. The result is the following folder structure:
D:\home>
D:\home\site>
D:\home\site\repository>
D:\home\site\repository\bin>
D:\home\site\repository\bin\Release>
D:\home\site\repository\bin\Release\netcoreapp2.1>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin>
D:\home\site\repository\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release\netcoreapp2.1\bin\Release>
This keeps on growing when more builds are executed.
In Visual Studio, cleaning and rebuilding helps solve it. After a few builds the filename becomes too long, raising an error when trying to run the application.
At first, it did not really matter, but when deploying the WebApp-Bot to Azure, the same happens. The problem is that I have no option to remove the excessive files from the server. Which is why I need to stop it from happening at all.
The .csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<UserSecretsId>SOME_USER_SECRETS_ID</UserSecretsId>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Compile Remove="%2a%2a\**" />
<Content Remove="%2a%2a\**" />
<EmbeddedResource Remove="%2a%2a\**" />
<None Remove="%2a%2a\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Gremlin.Net" Version="3.4.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.Bot.Builder.AI.Luis" Version="4.4.3" />
<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.4.3" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Version="4.4.3" />
<PackageReference Include="Microsoft.Recognizers.Text.DataTypes.TimexExpression" Version="1.1.6" />
</ItemGroup>
<Import Project="PostDeployScripts\IncludeSources.targets" Condition="Exists('PostDeployScripts\IncludeSources.targets')" />
<Import Project="..\PostDeployScripts\IncludeSources.targets" Condition="Exists('..\PostDeployScripts\IncludeSources.targets')" />
<ItemGroup>
<None Remove="%2a%2a\%2a.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="bin\" />
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties Properties_4launchSettings_1json__JSONSchema="" /></VisualStudio></ProjectExtensions>
</Project>
The includesources.targets, which I see now has the always flag:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Update="**\*.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>
<None Include="**\*.csproj" >
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="PostDeployScripts\*.*" >
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>
I would like to know why this happens and how to stop it, all help is welcome.
Your includesources.targets file has this little gem in it:
<Compile Update="**\*.cs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Compile>
Which would, if I understand correctly, cause the .cs files to be copied to your output folder. The next time a build is triggered, these files will probably also be compiled, creating a new bin\Release\netcoreapp2.1 from that location.
I'm not entirely sure what the targets file is there for, but I am pretty sure it's causing this issue. Try removing the file and the references to it from your .csproj, rebuild your project and see if you can deploy the bot.
I have some trouble with loading a System.Data.SQLite source solution. The System.Data.SQLite.2010 project seems to be empty, it is, indeed, does not contain references to files. However project file contains strings like these:
<Import Project="$(MSBuildProjectDirectory)\System.Data.SQLite.References.targets" />
<Import Project="$(MSBuildProjectDirectory)\System.Data.SQLite.Properties.targets" />
<Import Project="$(MSBuildProjectDirectory)\System.Data.SQLite.Files.targets" />
which, actually, contain references to files. But it's looks like this Import Project instructions are ignored by my VS. Is there is something I miss to do? Or maybe I need some plugin to install? Solution is builded successfully from VS, I just want to see files so I can navigate more easily on source.
You're not missing any plugins, nor is VS ignoring the Import directives. The import directives are used when build the project.
If you build the project, it builds fine and has all the classes that can be found in System.Data.SQLite*.cs.
I guess one of the reasons why this was done to protect 'core' framework files from accidental modification.
If you would like to see those files in your solution folder -
Open up System.Data.SQLite.Files.targets and System.Data.SQLite.2010.csproj in notepad or your favorite editor
Copy both ItemGroup nodes and paste them in System.Data.SQLite.2010.csproj
Comment out <Import Project="$(MSBuildProjectDirectory)\System.Data.SQLite.Files.targets" /> and save the csproj file.
Open up the solution file again or if already opened, reload the project to see the files.
Here's what my csproj looks after above modification:
<?xml version="1.0" encoding="utf-8"?>
<!--
*
* System.Data.SQLite.2010.csproj -
*
* Written by Joe Mistachkin.
* Released to the public domain, use at your own risk!
*
-->
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.30319</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AC139952-261A-4463-B6FA-AEBC25283A66}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>System.Data.SQLite</RootNamespace>
<AssemblyName>System.Data.SQLite</AssemblyName>
<OldToolsVersion>3.5</OldToolsVersion>
<SQLiteNetDir>$(MSBuildProjectDirectory)\..</SQLiteNetDir>
<ConfigurationYear>2010</ConfigurationYear>
</PropertyGroup>
<Import Project="$(SQLiteNetDir)\SQLite.NET.Settings.targets" />
<PropertyGroup Condition="'$(BinaryOutputPath)' != ''">
<OutputPath>$(BinaryOutputPath)</OutputPath>
<DocumentationFile>$(BinaryOutputPath)System.Data.SQLite.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<Import Project="$(MSBuildProjectDirectory)\System.Data.SQLite.References.targets" />
<Import Project="$(MSBuildProjectDirectory)\System.Data.SQLite.Properties.targets" />
<!--<Import Project="$(MSBuildProjectDirectory)\System.Data.SQLite.Files.targets" />-->
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="SQLite3.cs" />
<Compile Include="SQLite3_UTF16.cs" />
<Compile Include="SQLiteBase.cs" />
<Compile Include="SQLiteCommand.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="SQLiteCommandBuilder.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="SQLiteConnection.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="SQLiteConnectionPool.cs" />
<Compile Include="SQLiteConnectionStringBuilder.cs" />
<Compile Include="SQLiteConvert.cs" />
<Compile Include="SQLiteDataAdapter.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="SQLiteDataReader.cs" />
<Compile Include="SQLiteException.cs" />
<Compile Include="SQLiteFactory.cs" />
<Compile Include="SQLiteFunction.cs" />
<Compile Include="SQLiteFunctionAttribute.cs" />
<Compile Include="SQLiteKeyReader.cs" />
<Compile Include="SQLiteMetaDataCollectionNames.cs" />
<Compile Include="SQLiteParameter.cs" />
<Compile Include="SQLiteParameterCollection.cs" />
<Compile Include="SQLiteStatement.cs" />
<Compile Include="SQLiteTransaction.cs" />
<Compile Include="SR.Designer.cs">
<DependentUpon>SR.resx</DependentUpon>
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
</Compile>
<Compile Include="UnsafeNativeMethods.cs" />
<EmbeddedResource Include="SR.resx">
<SubType>Designer</SubType>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>SR.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup Condition="'$(IsCompactFramework)' == 'false'">
<Compile Include="SQLiteEnlistment.cs" />
<Compile Include="LINQ\SQLiteConnection_Linq.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="LINQ\SQLiteFactory_Linq.cs">
<SubType>Code</SubType>
</Compile>
<EmbeddedResource Include="SQLiteCommand.bmp" />
<EmbeddedResource Include="SQLiteConnection.bmp" />
<EmbeddedResource Include="SQLiteDataAdapter.bmp" />
</ItemGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
I have an XNA 3.1 content project (.contentproj) with the following:
<ItemGroup>
<Compile Include="tiles\B000N800.BMP">
<Name>B000N800</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
<Compile Include="tiles\B000N801.BMP">
<Name>B000N801</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
(... and so on ...)
</ItemGroup>
What I'd like to do is be able to specify a wildcard so that tiles\*.bmp gets compiled instead - so that I don't have to keep re-synchronising the content project when I add and remove textures from the "tiles" directory.
Does anyone know a way to do this?
Ideally the solution would ignore the hidden ".svn" directory, under "tiles". And also the content project would continue to work in Visual Studio.
You'll have to use wildcard in your item definition :
<ItemGroup>
<Compile Include="tiles\**\*.BMP"
Exclude="tiles\.svn\*">
<Name>%(Compile.Filename)</Name>
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</Compile>
</ItemGroup>
I found a blog post by Shawn Hargreaves that describes how to do this for XNA 1.0:
Wildcard content using MSBuild
Based on that, here is what I did which works with XNA 3.1 (and doesn't cause those weird _0 to appear):
Create a separate "tiles.proj" file with the following content:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<ItemGroup>
<WildcardContent Include="tiles\**\*.BMP" Exclude="tiles\.svn\*">
<Importer>TextureImporter</Importer>
<Processor>TextureProcessor</Processor>
</WildcardContent>
</ItemGroup>
<Target Name="BeforeBuild">
<CreateItem Include="#(WildcardContent)" AdditionalMetadata="Name=%(FileName)">
<Output TaskParameter="Include" ItemName="Compile" />
</CreateItem>
</Target>
</Project>
And in the original ".contentproj" file, right before </Project>, add:
<Import Project="tiles.proj" />