在Visual Studio 2019项目中的文件夹中自动包含文件

时间:2019-09-06 16:24:15

标签: visual-studio-2019

我有一些文件夹可以由第三方应用程序填充,并且我需要将所有文件存储为我的项目的一部分。甚至手动将它一个一个地包含在整个文件夹中是一件很烦人的事,因为每次新文件废除或删除时,我每次都要强迫它。

如何使用Visual Studio社区实现它?

1 个答案:

答案 0 :(得分:2)

我在使用webpack时遇到类似的问题。我不得不在webpack生成的Visual Studio中手动添加文件。您必须edit.csproj文件。

右键单击该项目,然后单击

卸载项目

右键单击已卸载的项目,然后单击

编辑YOUR_PROJECT_NAME.csproj

在下进行编辑,例如,我想在要发布它们时将/ Scripts / dist /下的所有文件都包括在内。 **包括所有文件或文件夹。 您还可以在VisualStudio documentation site上看到其他选项。

package com.github.ericytsang

import android.app.Instrumentation
import androidx.test.platform.app.InstrumentationRegistry
import io.realm.Realm
import io.realm.RealmConfiguration
import org.junit.Test

/**
 * tests to see how [Realm] works. nothing domain-specific here.
 *
 * cannot use Robolectric because https://github.com/robolectric/robolectric/issues/1389 :(
 * need to use Android instrumented tests.
 */
class GenericRealmTest {

    /**
     * [Realm.init] needs [Instrumentation.getTargetContext] to work; [Instrumentation.getContext]
     * will not work.
     */
    private val context = InstrumentationRegistry.getInstrumentation().targetContext

    private val db = run {
        Realm.init(context)
        Realm.getInstance(
            RealmConfiguration.Builder()
                .inMemory()
                .name("realm.db")
                .build()
        )
    }

    @Test
    fun teardown_works() = Unit
}

您也可以这样做

<ItemGroup>
   .... other items
   <Content Include="Scripts\dist\**" />
   .....other items
</ItemGroup> 

如果文件是从外部(例如Webpack)动态创建的,则还可以通过以下方式将其设置为不可见或隐藏(灰显):

<Content Include="css\*.min.css" />
<Content Include="js\*.min.js" />

注意:即使您看到文件变灰(好像不包括在内),在发布时也会包括这些文件。就我而言,当我刷新项目时就包含了它。